标签云

微信群

扫码加入我们

WeChat QR Code

我如何删除在git远程分支?[重复]

This question already has an answer here:

I created a branch notmaster to commit as well as push some changes. When I was finished with that branch, I merged the changes back into master, pushed them out, and then deleted the local notmaster.

$ git branch -a
* master
  remotes/origin/master
  remotes/origin/notmaster

Is there anyway to delete the remote notmaster?


A little more clarity, with the solution from Ionut:

The usual method failed for me:

$ git push origin :notmaster
error: dst refspec notmaster matches more than one.

That's because I had a tag with the same name as the branch. This was a poor choice on my behalf and caused the ambiguity. So in that case:

$ git push origin :refs/heads/notmaster


I Love you! I have been trying to get over the same problem for hours now! This is why I love StackOverflow +1!!!

2018年05月24日05分19秒

error: dst refspec notmaster matches more than one.

2018年05月24日05分19秒

That's a first. I haven't seen that error before.

2018年05月24日05分19秒

Ah, your second suggestion worked! I have a tag with the same label as that branch (notmaster). Could that cause the error?

2018年05月23日05分19秒

Oh, yes, that's the cause. I believe you could have deleted it using git push origin :refs/heads/notmaster. Not sure though.

2018年05月23日05分19秒

chrisaycock: And in fact, you need to do what Ionut suggests (disambiguate to refs/heads/notmaster) because with the git branch -d -r command, you've only deleted the local remote tracking branch, not the actual branch on the remote. If you don't delete it on the remote, it'll just show up the next time you fetch.

2018年05月23日05分19秒

that's tricky, exactly my problem!

2018年05月24日05分19秒

Smart! That works!

2018年05月24日05分19秒

The second of your two answers is what the OP was looking for, though it's by no means specific to gitorious, and you don't need a URL - just a remote name, which the OP gave. git push origin :notmaster, or in this case, git push origin :refs/heads/notmaster would be a clearer answer.

2018年05月23日05分19秒