While I understand that the command in the title is akin to undo the changes to the current repository, I am unable to understand how it actually works or how to read the command. Any leads would be a great help.
Asked
Active
Viewed 1.2k times
3
-
Pleas read any git tutorial, then you will understand what is git checkout, and it's not always undo changes – darvark Mar 24 '17 at 06:43
-
@darvark yes I do understand a checkout isn't undoing changes always, but when the git checkout command is succeeded by a dot (.), the explanations were a little ambiguous. I guess I wasn't clear on the command. – Srivatsa M Hegde Mar 24 '17 at 06:53
-
And https://stackoverflow.com/questions/8275452/dot-signs-meaning-in-git-checkout-command – 1615903 Mar 24 '17 at 07:08
-
One other noteworthy item: `git checkout
` does not undo changes to the *repository* but rather replaces files in the *work-tree*. The *repository* is the underlying Git database of commits. The work-tree (which is mostly a separate thing from the repository, although there's normally one work-tree associated with any given repository clone) is where you use and edit files in the normal form the computer knows how to deal with, instead of Git's special internal-only form. – torek Mar 24 '17 at 12:24
2 Answers
2
git checkout with
<paths>
[...] is used to restore modified or deleted paths to their original contents from the index or replace paths with the contents from a named (most often a commit-ish).
See documentation, especially here and here: .
is treated as <pathspec>
in your case, adressing the current directory. The current HEAD
revision of all files in the given <pathspec>
, so in your case everything in your base directory, are checked out.

kowsky
- 12,647
- 2
- 28
- 41
-3
git-checkout - Switch branches or restore working tree files
Example: git checkout -b [branch]

Awadhesh verma
- 530
- 4
- 10