Reputation: 51
I am beginner wit using git and I wanna know What this git command means
git checkout -- .
I know that git checkout is for switching between branches but I don't know whta the above options means I tried to look on toturials but I didn't options like this one
Upvotes: 0
Views: 6306
Reputation: 34987
It checks out the current directory and subdirectories.
tymtam@x:/mnt/c/tmp/x$ git status
modified: x.txt
modified: z/z1.txt
modified: z/z2/z2_1.txt
tymtam@x:/mnt/c/tmp/x$ cd z // changing to subdirectory
tymtam@x:/mnt/c/tmp/x/z$ git checkout -- .
tymtam@x:/mnt/c/tmp/x/z$ git status
modified: ../x.txt
(I removed git chatter for brevity)
Upvotes: 0
Reputation: 170735
Neither --
nor .
are git-specific:
The first
--
argument that is not an option-argument should be accepted as a delimiter indicating the end of options. Any following arguments should be treated as operands, even if they begin with the'-'
character.
.
is the current directory.
git checkout is for switching between branches
If you look at https://git-scm.com/docs/git-checkout, this command has the form
git checkout [<tree-ish>] [--] <pathspec>…
so it
Overwrite[s] paths in the working tree by replacing with the contents in the index or in the
<tree-ish>
(most often a commit).
"Paths" are .
(the current directory) and "the <tree-ish>
" is HEAD
(the current commit Git points to), because you didn't specify another.
Upvotes: 2