我可以在 git 上看到重命名分支的所有名称



我使用以下说明在 git repo 上重命名了我的分支:https://multiplestates.wordpress.com/2015/02/05/rename-a-local-and-remote-branch-in-git/

git branch -m new-name
git push origin :old-name new-name
git push origin -u new-name

现在当我做"git 分支 -a"时,我没有看到"旧名称"分支。但是,当我在另一台机器上这样做时,我会看到两个分支。此外,我可以"结帐"其中任何一个。我做错了什么?如何确保其他人看不到旧名称分支?

现在当我做git branch -a时,我看不到old-name分支。
但是当我在另一台机器上这样做时,我看到两个分支

您已在本地重命名分支,但未从远程中删除旧分支。

# rename the branch as you did
git branch -m <new name>
# now remove it form the remote and push the new one
git push origin --delete <old_branch>
# push the new name to the remote
git push origin <new branch> 
# now on the other machines fetch with the --prune to remove the old branch locally
git fetch --all --prune

注意
如果有人在重命名之前在本地签出此分支,他仍将将其作为本地分支保存在他的存储库中。
您无法通过从远程获取来删除本地分支

如何确保其他人看不到旧名称分支?

你必须告诉他们删除它。 如果他们已经签出了此分支,则除非在本地删除,否则无法将其删除。

最新更新