7

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?

adnan.c
  • 721
  • 5
  • 15

1 Answers1

8

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.

Ammar Husain
  • 1,789
  • 2
  • 12
  • 26
  • It worked in RStudio. I just undid the changes in the editor and got back the discarded changes. – jorvaor Jun 02 '21 at 17:32