seadowbay
seadowbay

Reputation: 1

"git checkout ../../..": what does it mean

I accidentally type

git checkout ../../..

when I actually meant

cd ../../..

I realize all my uncommitted changes are gone. Is there anyway I can recover them?

Thanks!

Upvotes: 0

Views: 39

Answers (1)

torek
torek

Reputation: 488083

If you used git checkout path and it overwrote uncommitted changes, those changes are generally gone without the ability to recover (though your OS may offer some non-Git method, e.g., Time Machine on OS X). See also Get back the changes after accidental checkout?

Your subject line asks what:

git checkout ../../..

means. It tells Git that Git should check out the directory ../../.. from the current commit, i.e., from whatever sub-sub-sub-directory you are in—such as a/b/c/ if your layout includes a top level directory a, subdirectory b within a, and subdirectory c within b. In thiat particular case—climbing up three levels, from a directory three levels down—you would arrive at your top level directory, so this would check out (extract) every file that is in the index, overwriting the work-tree versions.

If you were four levels down—e.g., in a/b/c/d/—this would tell Git to overwrite the work-tree copy of every file in a/ from the index copy.

Upvotes: 1

Related Questions