Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to undo a git checkout for a modified file [duplicate]

Tags:

git

In more than one occasion, I found myself accidentally doing a git checkout /path/to/file which erased my local change in the file, the changes were not added/committed.

Any way to undo that?

like image 592
adnan.c Avatar asked Mar 07 '23 22:03

adnan.c


1 Answers

There is no way to undo that in git.

However if you have the file open in your editor you can undo the changes there. Some editors like Emacs auto save files, so try looking for files with the same file name and a ~ or # extensions.

like image 135
Ammar Husain Avatar answered Mar 20 '23 02:03

Ammar Husain