0

I was working on my project, and I made a wrong commit (the last commit) and wanted to permanently delete it from the git logs, and I did the following command:

git reset --hard HEAD^

The problem is that I didn't make add on my changes, so all changes which are unstaged were deleted.

Now, how do I get all the changes back?

mkrieger1
  • 19,194
  • 5
  • 54
  • 65
  • @jonrsharpe no, I tried but to no avail, it seems that they has staged their changes . – user11555842 Jun 25 '23 at 17:16
  • 1
    Also e.g. https://stackoverflow.com/q/25791533/3001761 - there are plenty of git-related posts here already, not to mention resources like https://ohshitgit.com/. – jonrsharpe Jun 25 '23 at 18:19
  • Will this post not work : https://stackoverflow.com/questions/5473/how-can-i-undo-git-reset-hard-head1 – mgillett Jun 25 '23 at 18:28

1 Answers1

2

As the git documentation specifies:

git reset
--hard Resets the index and working tree. Any changes to tracked files in the working tree since are discarded.

If there is no restore source (stash, add, commit) I know of no way to restore your files since git doesn't 'auto-updates' a current snapshot of your working tree

Michael
  • 31
  • 4