开发者

How do you delete a remote git branch "properly", a.k.a. updating the remote branch list for all users?

开发者 https://www.devze.com 2023-02-14 10:24 出处:网络
I\'m trying to delete a remote git branch, however the process isn\'t \"fully\" deleting the branch as I\'d expect.

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 updati开发者_StackOverflow中文版ng 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?


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 or git 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.

git fetch -p
0

精彩评论

暂无评论...
验证码 换一张
取 消