Somebody pushed a branch called test
with git push origin test
to a shared repository. I can see the branch with git branch -r
.
Other guys and gals give the solutions, but maybe I can tell you why.
git checkout test which does nothing
Does nothing
doesn't equal doesn't work
, so I guess when you type 'git checkout test' in your terminal and press enter key, no message appears and no error occurs. Am I right?
If the answer is 'yes', I can tell you the cause.
The cause is that there is a file (or folder) named 'test' in your work tree.
When git checkout xxx
parsed,
xxx
as a branch name at first, but there isn't any branch named test.xxx
is a path, and fortunately (or unfortunately), there is a file named test. So git checkout xxx
means discard any modification in xxx
file.xxx
either, then Git will try to create the xxx
according to some rules. One of the rules is create a branch named xxx
if remotes/origin/xxx
exists.