Git:更新远程分支信息
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3993426/
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
Git: updating remote branch information
提问by Bain Markev
In a git repository, a remote branch I am not tracking was deleted. When I type
在 git 存储库中,我没有跟踪的远程分支被删除。当我打字
git branch -r
the deleted branch still shows up (and I can check it out)
删除的分支仍然出现(我可以检查出来)
What git command do I have to run to update this info?
我必须运行什么 git 命令才能更新此信息?
采纳答案by Garrett Hyde
If you perform something like
如果您执行类似的操作
git branch -d -r remote_name/branch_name
you only remove your local checkout. This command doesn't do anything to the remote repository, which is why it still shows up.
您只需删除本地结帐。此命令不会对远程存储库执行任何操作,这就是它仍然显示的原因。
Solution:
解决方案:
git push origin :branch_name
will remove the the remote branch (note the ':'), and
将删除远程分支(注意':'),和
git branch -d branch_name
will remove your local checkout.
将删除您的本地结帐。
(参考)
回答by Jakub Nar?bski
If it were branches in remote repositorythat got deleted, and you want to update all local remote-tracking branches at once, you can use
如果是远程存储库中的分支被删除,并且您想一次更新所有本地远程跟踪分支,则可以使用
$ git remote prune <remotename>
to delete all stale remote-tracking branches for a given remote (i.e. those that follow branches which were removed in remote repository).
删除给定远程的所有陈旧的远程跟踪分支(即那些跟随在远程存储库中删除的分支的分支)。
See git remote
documentation.
请参阅git remote
文档。
回答by Flo
git remote update --prune
Should refresh all remotes' branches, adding new ones and deleting removed ones.
应该刷新所有遥控器的分支,添加新的和删除删除的。
Edit:
The remote updatecommand basically fetches the list of branches on the remote.
The --prune
option will get rid of your localremote tracking branches that point to branches that no longer exist on the remote.
编辑:远程更新命令基本上获取远程分支列表。该--prune
选项将删除您的本地远程跟踪分支,这些分支指向远程上不再存在的分支。
回答by Aidan Donohoe
Also useful for seeing new remote branches:
对于查看新的远程分支也很有用:
git fetch --all
回答by mikerobi
You can combine the -r
and -d
flags to delete remote branches.
您可以结合使用-r
和-d
标志来删除远程分支。
回答by MarceloCouto
Try this command
试试这个命令
git gc --prune=now