Reputation: 16285
I know this has been covered before, but I have tried the following and can't seem to delete the remote branch.
aly@neon:~/workspace/3DOD_VARIANCE$ git branch -a
* master
remotes/origin/HEAD -> origin/master
remotes/origin/master
remotes/origin/multi_gauss_at_nodes
remotes/origin/old-state-with-mean-deviation-from-centre
remotes/origin/variance-branch
aly@neon:~/workspace/3DOD_VARIANCE$ git branch -r -d origin/old-state-with-mean-deviation-from-centre Deleted remote branch origin/old-state-with-mean-deviation-from-centre (was 0ed90b2).
Fetching origin
From https://bitbucket.org/alykhantejani/3dobjectdetection
* [new branch] old-state-with-mean-deviation-from-centre -> origin/old-state-with-mean-deviation-from-centre
As you can see the branch has been fetched again. Any idea what I'm doing wrong?
Also, as a side note, is there a way for me to check if this branch has already been merged back into master before I delete?
Upvotes: 34
Views: 24324
Reputation: 14714
From @Matthew Rankin's answer:
As of Git v1.7.0, you can delete a remote branch using
$ git push <remote_name> --delete <branch_name>
Upvotes: 13
Reputation: 7020
The full push command is the following
git push <remote name> <local branch>:<remote branch>
Just send "no branch at all" to the remote server that way:
git push origin :old-state-with-mean-deviation-from-centre
For the sidenote : git prevents you to delete branch that has not been merged when you use "git branch -d " (and tells you to use -D if you are really sure to delete it anyway).
Also notice the git branch -d -r <branch name>
delete the references in your .git folder (and not the real branch located on the remote server), that's why a new fetch will re create it
Upvotes: 38
Reputation: 4397
To delete a remote branch run following:
git push origin :branch-to-delete
The trick is in colon
Upvotes: 54