This question’s answers are a community effort. Edit existing answers to improve this post. It is not currently accepting new answers or interactions.
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.
How do I properly delete the remotes/origin/bugfix branch both locally and remotely?
Executive Summary git push -d remote_name> (branch name>) # Delete remote gi branch –d (d-BranchName> # ‘Delete local’)\n\nNote: In most cases, remote_name> will be the source. Delete Local Branch To delete the local branch, use one of the following: git branch -d \’branch_ name> git branch-D .\n\nThe -d option is an alias for –delete, which deletes the branch if it has already been fully merged in its upstream branch; [Source: man git-branch] As of Git v2.3, the \’D option\’ removes this branch \”irrespective of its \”merged\” status, whether you try to delete the currently selected branch or not.\”\n\nFor example, Delete Remote Branch As of Git v1.7.0 removes a remote branch with $ git push remote_name> –delete \’branch_ name>.\n\nThis may be easier to remember than $ git push remote_name> :branch_ name>:: .\n\nUsing the -d option as an alias for –delete, you can use git push from the Git v1.5.0 \”to delete a remote branch\” or \”tag.\” Hence, the version of the code you installed will decide whether you need to use the easier or harder syntax. Delete Remote Branch [Original Answer from 5-Jan-2010] From Chapter 3 of Pro Gitian by Scott Chacon:\n\nIf you want to remove your server branch from the server using the rather obtuse syntax git push :serverfix To [email protected]:schacon/simplegit – [deleted] serverfix, you and your collaborators are done with this feature and have merged it into your remote’s main branch (or whatever branch your stable code-line is in) .\n\nBoom. No more branches on your server. You may want to dog-ear this page, because you’ll need that command, and you will probably forget the syntax. A way to remember this command is the git push [remotename] syntax that we overtook a bit earlier. If you leave off the part of the [ localbrain] and then say, “Take nothing on my side and make it be [reason]].”\n\nI ran git push origin :bugfix, and it worked. Scott Chacon was right—I will want to dog-ear that page (or virtually dog ear-by answering this on Stack Overflow) Fetch changes from all remotes and locally delete # remote deleted branches/tags etc. # –prune will do the job – ; GitHub fetch fetch –all—prunce.