May 3, 2018

Delete a Git branch both locally and remotely

Delete Remote Branch

$ git push <remote_name> --delete <branch_name>

Delete Local Branch

$ git branch -d branch_name
$ git branch -D branch_name

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.