Thursday, November 17, 2016

Delete Git Branch Local and Remote

Executive Summary

$ git branch -d 
$ git push origin --delete 

Delete Local Branch

To delete the local branch use:
$ git branch -d branch_name
Note: The -d option is an alias for --delete, which only deletes the branch if it has already been fully merged in its upstream branch. You could also use -D, which is an alias for --delete --force, which deletes the branch "irrespective of its merged status." [Source: man git-branch]

Delete Remote Branch [Updated on 1-Feb-2012]

As of Git v1.7.0, you can delete a remote branch using
$ git push origin --delete 
which might be easier to remember than
$ git push origin :