How to delete a Git branch both locally and remotely?

January 20, 2019

This is a question that often comes up in a team environment when using Git.

I'm trying to remove a branch both locally and remotely on my fork...

How do I delete this branch both locally and on Github?...

Deleting a remote branch:

git push origin --delete <BRANCH_NAME>

Note that origin could be changed to upstream if you're trying to remove the branch from the upstream (original) repository of your fork.

Deleting Local Branches:

git branch -d <BRANCH_NAME>

Using -D instead of -d forces the delete, where -d will warn you if the branch hasn't been merged.