tl;dr: git checkout master
does not switch to master branch, gives no error or any output at all and I have no clue why. Any other branch works fine.
I have a git repository that consists of the branches development
and master
. I do a fresh clone of the repository, checking out branch development
as default.
$ git clone <REPO-URL> --branch development
$ git branch -a
* development
origin/HEAD -> origin/development
origin/development
origin/master
$ git show-ref
656c781c2affc26792f857baf8e232de07101535 refs/heads/development
656c781c2affc26792f857baf8e232de07101535 refs/remotes/origin/HEAD
656c781c2affc26792f857baf8e232de07101535 refs/remotes/origin/development
cfee1a1761642453edf5d001565f23b50243ff09 refs/remotes/origin/master
The ref master is pointing to is correct, that commit does exists and is the latest commit of my master branch.
So far everything looks normal, but when I try to switch to master this is happening:
$ git checkout master
$ git branch
* development
No message from checkout, no error, nothing, and the branch is not switched.
Things I have tried so far:
master2
from the same commit => checkout works fine.git checkout -b master --track origin/master
=> works, but I think it should not be necessary to use this command as this is what git checkout master
should do automaticallyAny further ideas? What am I missing? Is my repository broken? How can I fix this?
If your repo has a folder or file name the same as a branch name then you will need to: git checkout xyz --
with the extra --
at the end. It tells git to use a branch or commit instead of trying to use a folder/file name.
Found the answer on another stackoverflow post: Git change branch when file of same name is present