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?
Currently, the all-encompassing command – git checkout does many things. It can be used to switch branches and also to restore the working tree files.
Force a Checkout You can pass the -f or --force option with the git checkout command to force Git to switch branches, even if you have un-staged changes (in other words, the index of the working tree differs from HEAD ). Basically, it can be used to throw away local changes.
In summation, git checkout , when used on branches, alters the target of the HEAD ref. It can be used to create branches, switch branches, and checkout remote branches. The git checkout command is an essential tool for standard Git operation. It is a counterpart to git merge .
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With