简体   繁体   English

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

[英]I can see all names for a renamed branch on git

I renamed my branch on git repo using these instructions: https://multiplestates.wordpress.com/2015/02/05/rename-a-local-and-remote-branch-in-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

Now when I do 'git branch -a', I do not see the 'old-name' branch. 现在,当我执行“ git branch -a”时,看不到“旧名称”分支。 However when I do so on another machine I see both branches. 但是,当我在另一台计算机上这样做时,我会看到两个分支。 Furthermore, I can 'git checkout' any of them. 此外,我可以“ git checkout”其中的任何一个。 What did I do wrong? 我做错了什么? How can I ensure that other people do not see the old-name branch? 如何确保其他人看不到旧名称分支?

Now when I do git branch -a , I do not see the old-name branch. 现在,当我执行git branch -a ,看不到old-name分支。
However when I do so on another machine I see both branches 但是,当我在另一台计算机上这样做时,我看到两个分支

You have renamed the branch locally and you did not removed the old one from the remote. 您已经在本地重命名了分支并且没有从远程站点中删除了旧的分支。

# 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

NOTE 注意
If some one checkout this branch locally before the rename, he will still have it locally on his repository as local branch. 如果在重命名之前有人在本地检出此分支,则他仍会将其作为本地分支保存在本地存储库中。
You cannot remove local branches by fetching from remote 您无法通过从远程获取来删除本地分支

How can I ensure that other people do not see the old-name branch? 如何确保其他人看不到旧名称分支?

You have to tell them to delete it. 您必须告诉他们将其删除。 if they have already checked out this branch you cant remove it unless deleted locally. 如果他们已经签出了此分支,则除非在本地删除,否则无法将其删除。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM