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

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).

Leave a Comment