What does "git checkout - ." do?
10,782
git checkout -
checks out the previously checked out branch. So I would assume that git checkout - .
will replace the contents of the working copy with the contents of the previously checked out branch.
You can not undo that, but since you wanted to reset the contents of your working dir anyways, why don’t you just run git checkout -- .
?
You might want to use git reset --hard
in the future to undo all changes against the current branch. It also resets the index.
Related videos on Youtube
Comments
-
Ricardo Acras over 1 year
I wanted to revert all local changes with
git checkout -- .
but accidently did
git checkout - .
and it made lots of local modifications that I can't understand at all.
What does the second command do and is it possible to revert what was done?
-
twalberg almost 11 years@CharlesB @Layke No, specifying
-
as the branch to check out is well defined and documented. It's equivalent to@{-1}
.
-