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 which I have cloned from Github. The repository has several branches. I worked on the master branch for a while but then needed to switch to one of the other branches.
So, I had:
$ git branch --all
* master
remotes/origin/abc
remotes/origin/def
remotes/origin/HEAD -> origin/master
remotes/origin/ghi
Problem: I wanted to switch to the 'abc' branch but instead of doing git checkout remotes/origin/abc
I accidentally did git branch remotes/origin/abc
which leaves me with the following:
$ git branch --all
* master
remotes/origin/abc
remotes/origin/abc
remotes/origin/def
remotes/origin/HEAD -> origin/master
remotes/origin/ghi
My questions are:
- Why on Earth does Git allow you to create two branches with the same name?
- How do I identify which is the real remotes/origin/abc branch?
- How do I remove the unwanted remotes/origin/abc that I created by accident?
Any help much appreciated.