0

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

8

2 Answers 2

1

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.

(from https://unix.stackexchange.com/questions/11376/what-does-double-dash-mean-also-known-as-bare-double-dash/11378).

. 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.

0
0

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)

1
  • git status -sb can really cut away the chatter :) Oct 19, 2019 at 13:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.