What difference between next 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 second command, everything is ok?
With branch specifier only ( git checkout branch ) it will switch current working directory to specified branch, keeping local changes if possible and failing otherwise. If you already are on branch , it will do nothing at all.
In order to checkout a Git tag, use the “git checkout” command and specify the tagname as well as the branch to be checked out. Note that you will have to make sure that you have the latest tag list from your remote repository.
You can not only create a new branch but also switch it simultaneously by a single command. The git checkout -b option is a convenience flag that performs run git branch <new-branch>operation before running git checkout <new-branch>. Syntax: $ git checkout -b <branchname>
git checkout -b BRANCH_NAME creates a new branch and checks out the new branch while git branch BRANCH_NAME creates a new branch but leaves you on the same branch.
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 on branch
, it will do nothing at all. It only modifies files in the working directory that differ between HEAD
and branch
and 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, use git reset
with path specifier.git checkout branch .
) it writes content in specified revision. It will not modify where HEAD
points, so if branch
is different from HEAD
, 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.
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