How do I delete a git branch locally and remotely?
Git branches are an essential part of your daily development process, but once you or your team have finished with a feature and merged it into your remote's master branch, you would want to delete it from the local and as your remote. You can do it in two ways:
git push --delete <remote_name> <branch_name>
To delete a local branch, use the following:
git branch -d <branch_name>
Note:
-d
option forgit branch
the command is an alias of--delete
flag, which deletes the branch if it has already merged in its upstream branch.-D
is also an option--delete
flag, which deletes the branch "regardless of its merged status."