Original question: Delete a Git branch both locally and remotely by Matthew Rankin
I want to delete a branch both locally and at the branch of my remote project on Github.
Deleted local branch successfully
$ git branch -D bugfix
Deleted branch bugfix (was 2a14ef7).
Note: The -D
option is a shortcut of --delete --force
. If you want to remove the local branch that must be fully merged in the upper branches, use -d
which is a shortcut of -delete
.
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.
What do I need to do differently to successfully remove the remotes / origin / bugfix branch both locally and on Github?