如何删除本地 git 存储库中的远程分支?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6940595/
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 can I delete a remote branch in a local git repository?
提问by Talespin_Kit
All the remote branches are visible as remotes in my local git repository after a git fetch.
在 git fetch 之后,所有远程分支在我的本地 git 存储库中都作为远程可见。
How to selectively remove the remote branches in my local repository (not in the remote repository)?
如何有选择地删除本地存储库中的远程分支(不在远程存储库中)?
回答by Thomas Levesque
I had a slightly different but similar issue, but the solution might be useful to others who stumble on this question...
我有一个稍微不同但相似的问题,但该解决方案可能对偶然发现这个问题的其他人有用......
I noticed that my local repository still had remote branches that no longer existed on the remote, so I wanted to remove them. The solution is simply to fetch with the --prune
(or -p
) option:
我注意到我的本地存储库仍然有远程分支不再存在于远程,所以我想删除它们。解决方案只是使用--prune
(or -p
) 选项获取:
git fetch --prune
回答by Ilya Ivanov
git branch -r -d remote/branch
git branch -r -d remote/branch
You also need to reconfigure fetch to avoid fetching this branch again later
您还需要重新配置 fetch 以避免稍后再次获取此分支