0

I wanted to get back to the last commit to see if it was still working back then. I was doing this in Eclipse and chose

Show in History -> Second latest commit in Master -> Reset (Hard)

I did a hard reset because I wanted my files to be the same as they were in that commit. Would a checkout have been sufficient?

I can't see my latest commit anymore. Is it gone now?

neolith
  • 699
  • 1
  • 11
  • 20
  • 1
    Does this answer your question? [How can I undo git reset --hard HEAD~1?](https://stackoverflow.com/questions/5473/how-can-i-undo-git-reset-hard-head1) - `git reflog` is a great tool to be familiar with :). – AD7six Mar 17 '21 at 12:01
  • So I need the checksum. Problem is because I did this in Eclipse, I have no history of commands as I would have by doing this in the terminal – neolith Mar 17 '21 at 12:05
  • @AD7six Phew, I could see the checksum by typing ``git reflog`` and then reset back. Thx! – neolith Mar 17 '21 at 12:08
  • Eclipse has a local history. Try 'Replace with > Local History' on individual files, or 'Restore From > Local History' for deleted files. – greg-449 Mar 17 '21 at 12:08

1 Answers1

0

git reset --hard overwrites your files with a copy from the repository.

If those changes were part of another commit, you can usually find that commit with git reflog - it will be somewhere near the top.

Otherwise, unless you made a backup yourself, that information is not stored in Git and you cannot get it back.

In some cases (i.e. if you are using Jetbrains IDEs) there is an option of "local history" where the IDE will keep an automated backup of your files for some time.

jurez
  • 4,436
  • 2
  • 12
  • 20
  • I remember that last time in the terminal I could get back by typing the checsum of the commit. – neolith Mar 17 '21 at 12:04