Active reading [<http://en.wikipedia.org/wiki/Git_%28software%29>]
Source Link
Peter Mortensen
  • 29.1k
  • 21
  • 97
  • 124

AnotherOther 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,

  1. gitGit looks on xxx as a brachbranch name at first, but there isn't any branch which is named test.
  2. then gitThen Git thinks xxx is a path, and fortunately (or unfortunately), there is a file named test. soSo git checkout xxx means discardsdiscard any modification in xxx file.
  3. ifIf there isn't file named xxx either, then gitGit 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.

Another guys 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,

  1. git looks on xxx as a brach name at first, but there isn't any branch which is named test.
  2. then git thinks xxx is a path, fortunately (or unfortunately), there is a file named test. so git checkout xxx means discards any modification in xxx file
  3. 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 xxx if remotes/origin/xxx exists.

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,

  1. Git looks on xxx as a branch name at first, but there isn't any branch named test.
  2. 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 xxx file.
  3. 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 xxx if remotes/origin/xxx exists.
Source Link
oldman
  • 4.2k
  • 2
  • 18
  • 15

Another guys 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,

  1. git looks on xxx as a brach name at first, but there isn't any branch which is named test.
  2. then git thinks xxx is a path, fortunately (or unfortunately), there is a file named test. so git checkout xxx means discards any modification in xxx file
  3. 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 xxx if remotes/origin/xxx exists.