git-push - View 3+ more - How do I delete a Git branch locally and remotely?

git push new branch / git / version-control / git-branch / git-remote

I want to delete a branch both locally and remotely.

Failed Attempts to Delete a Remote Branch

$ git branch -d remotes/origin/bugfix
error: branch 'remotes/origin/bugfix' not found.

$ git branch -d origin/bugfix
error: branch 'origin/bugfix' not found.

$ git branch -rd origin/bugfix
Deleted remote branch origin/bugfix (was 2a14ef7).

$ git push
Everything up-to-date

$ git pull
From github.com:gituser/gitproject

* [new branch] bugfix -> origin/bugfix
Already up-to-date.

Matthew Rankin



Answer #1

To delete the remote branch

git push -d origin <branch-name>
git push origin :<branch-name>

To forcefully delete local branch

git branch -D <branch-name>