How can I undo that unstaged changes were deleted by git reset --hard HEAD^?

164 Views Asked by At

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?

1

There are 1 best solutions below

0
Michael On

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