What is the difference between the following git commands:
git checkout branch
git checkout branch .
git checkout . #<-- used at the branch
Why when I checkout different branches into different folders with first one I missed some files.
But when I am using the second command, everything is ok?
git checkout(1) does very different things whether given path specifier or not.git checkout branch) it will switch current working directory to specified branch, keeping local changes if possible and failing otherwise. If you already are onbranch, it will do nothing at all. It only modifies files in the working directory that differ betweenHEADandbranchand fails if any of them has local modifications (indexed or not)..) with specified content:git checkout .) it writes content from index. That is, it undoes unstaged local modification. To undo staged modifications, usegit resetwith path specifier.git checkout branch .) it writes content in specified revision. It will not modify whereHEADpoints, so ifbranchis different fromHEAD, there will be unstaged changes afterwards.Note, that the man page distinguishes additional cases for use of the -b/–branch option and -p/–patch option, but those are mostly straightforward extensions of the above cases.