How To Delete a Git Branch - Locally and Remotely

Branching is great, it does, however, look much better if you remember to remove your old branches so they don’t take up unnecessary space. This is how.

Delete a local branch

Deleting a local branch is the simplest of the two.

git branch -d branchToDelete

If you have unstaged changes, you need to force the removal with a capital D instead.

git branch -D branchToDelete

Delete a remote branch

Deleting a branch remotely actually requires a push, but it’s quite simple as well.

git push origin --delete branchToDelete