如何“正确”删除远程 git 分支,也就是更新所有用户的远程分支列表?
我正在尝试删除远程 git 分支,但是该过程并未像我预期的那样“完全”删除该分支。
比方说,我要删除一个名为 mybranch
的分支。为此,我运行以下命令,
git push origin :mybranch
这将按预期删除分支,如果我执行 gitbranch -a ,它就不再出现在本地或远程列表中。
我遇到的问题是,如果我在另一个人的机器上执行了 git pull
而分支存在,并且他们执行了 gitbranch -a
,它仍然在他们的列为远程分支。
我们尝试了多个命令,pull
、gc
、prune
,但没有任何命令更新此列表并删除远程分支。
是否有一个命令可以同步(我只能假设是)远程分支列表的本地缓存,并删除不再存在的任何远程分支?
I'm trying to delete a remote git branch, however the process isn't "fully" deleting the branch as I'd expect.
Let's say for example I'm deleting a branch called mybranch
. To do this, I run the following command,
git push origin :mybranch
This removes the branch as expected, and if I do git branch -a
it no longer appears on the list locally or remotely.
The problem I'm having is if I go another person's machine who did a git pull
while the branch existed, and they perform a git branch -a
, it's still in their list as a remote branch.
We've tried multiple commands, pull
, gc
, prune
, but nothing is updating this list and removing the remote branch.
Is there a command to sync (what I can only assume is) the local cache of the remote branches list, and remove any remote branches that no longer exist?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在他们更新遥控器之前,他们的 git 将不知道存储库中发生了什么。一旦他们完成更新(通过
git fetch
或git远程更新
),git remote show origin
将正确显示他们有本地跟踪上游不再存在的分支的分支。此时,可以使用 git Remote prune 删除过时的本地分支。Until they update their remotes, their git will have no knowledge of what's happened on the repository. Once they've done an update (via
git fetch
orgit remote update
),git remote show origin
will correctly show that they have local tracking branches for branches that no longer exist upstream. At that point,git remote prune
can be used to remove the stale local branches.删除远程上不再存在的任何远程跟踪分支。
To remove any remote-tracking branches which no longer exist on the remote.