How to Delete a Git Branch Locally and Remotely
Delete Local Branch
1
$ git branch -d <the_local_branch_name>
The above command will:
- Delete the local branch. You will receive an error if you try to delete the currently selected branch.
- Use
-D
(replace-d
in the above command) to force delete the branch without checking merged status.
Delete Remote Branch
1
$ git push origin --delete <the_remote_branch_name>
The above command will:
- Remove a remote branch from the server.