从已删除的远程分支的原点获取?
当我执行 git fetch origin 且 origin 有一个已删除的分支时,它似乎没有在我的存储库中更新它。当我执行 git Branch -r 时,它仍然显示 origin/DELETED_BRANCH 。
我该如何解决这个问题?
When I do git fetch origin
and origin has a deleted branch, it doesn't seem to update it in my repository. When I do git branch -r
it still shows origin/DELETED_BRANCH
.
How can I fix this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
您需要执行以下操作
-p
或--prune
参数将更新远程分支的本地数据库。You need to do the following
The
-p
or--prune
argument will update the local database of remote branches.来自 http://www.gitguys.com/topics/adding-and-removing-remote-分支/
请注意, git fetch -p 中的 -p 参数实际上意味着“修剪”。
无论您选择哪种方式,不存在的远程分支都将从本地存储库中删除。
From http://www.gitguys.com/topics/adding-and-removing-remote-branches/
As a note, the -p param from
git fetch -p
actually means "prune".Either way you chose, the non-existing remote branches will be deleted from your local repository.
您需要执行以下操作
才能同步您的分支列表。 git 手册说
我个人喜欢使用 git fetch origin -p --progress ,因为它显示进度指示器。
You need to do the following
in order to synchronize your branch list. The git manual says
I personally like to use
git fetch origin -p --progress
because it shows a progress indicator.这对我有用。
This worked for me.
关于 git fetch -p ,其行为在 Git 1.9 中发生了变化,只有 Git 2.9.x/2.10 反映了这一点。
请参阅 提交 9e70233(2016 年 6 月 13 日),作者:杰夫·金 (
peff
)。(由 Junio C Hamano --
gitster
-- 合并于 提交 1c22105,2016 年 7 月 6 日)所以文档现在指出:
这是因为:
Regarding
git fetch -p
, its behavior changed in Git 1.9, and only Git 2.9.x/2.10 reflects that.See commit 9e70233 (13 Jun 2016) by Jeff King (
peff
).(Merged by Junio C Hamano --
gitster
-- in commit 1c22105, 06 Jul 2016)So the documentation now states:
That is because:
对于比版本
2.x
更新的git
和Apple git
这对我有用:For
git
andApple git
newer than version2.x
this worked for me:如果 git fetch -p origin 因某种原因不起作用(例如,由于原始存储库不再存在或您无法访问它),另一种解决方案是删除本地存储的信息通过从存储库的根目录进行分支:
或者如果它存储在文件
.git/packed-refs
中,则删除相应的行,如下所示If
git fetch -p origin
does not work for some reason (like because the origin repo no longer exists or you are unable to reach it), another solution is to remove the information which is stored locally on that branch by doing from the root of the repo:or if it is stored in the file
.git/packed-refs
by deleting the corresponding line which is like中的配置值
这现在是 .gitconfig [fetch]
prune = true
https://git-scm.com /docs/git-config#Documentation/git-config.txt-fetchprune
This is now a configuration value in .gitconfig
[fetch]
prune = true
https://git-scm.com/docs/git-config#Documentation/git-config.txt-fetchprune