Why has Git allowed me to create two branches with the same name?

前端 未结 5 1227
不思量自难忘°
不思量自难忘° 2020-12-29 18:09

I\'m still relatively new to Git and I have made a bit of a mess of my repository. I\'m hoping there is a way to fix it without re-cloning.

I have a repository whic

5条回答
  •  清歌不尽
    2020-12-29 18:52

    You can't create two local branches or two distant branches with the same name.

    • Here you have a local branch named remotes/origin/abc and a distant branch named abc on the remote origin. They have not the same name, but it seems to when you use the git branch --all command.

    • To identify which branch is which, you can show local branches with git branch, or show remote branches with git branch --remote. You could also easily differentiate them even while using git branch --all with the branch syntax coloration (git config --global color.branch auto).

    • To remove the accidentally created local branch abc, you have to do git branch -d abc (or git branch -D abc to force deletion, see man git-branch).

提交回复
热议问题