git 如何从命令行删除远程分支(例如 Github)?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/39853125/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to delete remote branch (e.g. Github) from command line?
提问by Masked Man
I have a git repository in my local machine:
I add a new branch called test
and add a few commits
Then I checkout to master
branch and add commits to it.
So I use git push --all github
and continue working on master.
After some time I decide to completely remove the test
branch and use: git branch -d test
and git branch -r -d github/test
, but it only deletes the local branch used for tracking the actual test
branch as git says:
我的本地机器上有一个 git 存储库:
我添加了一个名为的新分支test
并添加了一些提交
然后我结帐到master
分支并将提交添加到它。
所以我使用git push --all github
并继续在 master 上工作。一段时间后,我决定完全删除test
分支并使用: git branch -d test
and git branch -r -d github/test
,但它只删除用于跟踪实际test
分支的本地分支,如 git 所说:
Deleted remote-tracking branch github/buggy (was acc5a58).
删除了远程跟踪分支 github/buggy(原为 acc5a58)。
I'm asking if there's a way to actually remove the test
branch from github servers from command-line?
我在问是否有办法test
从命令行从 github 服务器中实际删除分支?
采纳答案by Arkadiusz Drabczyk
As with every git
server:
与每台git
服务器一样:
$ git push github :<BRANCH_NAME>
or:
或者:
$ git push github --delete <BRANCH_NAME>
Example:
例子:
$ git push github --delete test
回答by Mihir Patel
Local Branch
本地分行
git branch -d local_branch
Remote Branch
远程分支
git push origin --delete remote_branch
回答by blue112
Use this command:
使用这个命令:
git push github :test
Read "push nothing as refname test
on github remote"
阅读“test
在 github 远程推送任何内容作为 refname ”