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.
git checkout xxx parsed,
- Git looks on
xxx as a branch name at first, but there isn't any branch named test.
- Then Git thinks
xxx is a path, and fortunately (or unfortunately), there is a file named test. So
git checkout xxx means discard any modification in
- If there isn't file named
xxx either, then Git will try to create the
xxx according to some rules. One of the rules is create a branch named