Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does "git checkout - ." do?

Tags:

git

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?

like image 378
Ricardo Acras Avatar asked Jul 11 '13 17:07

Ricardo Acras


1 Answers

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.

like image 99
Chronial Avatar answered Oct 16 '22 20:10

Chronial