git命令行删除远程分支

先查看远程分支

git branch -r


使用下面两条命令来删除远程分支

git branch -r -d origin/branch-name
git push origin :branch-name

update:

解释一下上面的参数含义:

-r, --remotes
List or delete (if used with -d) the remote-tracking branches.


上面的第一句是删除了本地的远程跟踪分支( 我也不知道怎么描述更加清楚),此时使用git branch -a查看,分支remotes/origin/branch-name应该已经不存在了。

为什么还需要第二句,因为上面只是把本地的远程跟踪分支删除了,远程的分支还没有删除,所以第二句就是真正的删除原种分支。

若出现错误  重新操作  

Pushing an empty <src> allows you to delete the <dst> ref from the remote repository.
原文地址:https://www.cnblogs.com/mzdljgz/p/11475636.html