Is there any way to recover uncommitted changes to the working directory from a git reset --hard HEAD
?
The information is lost.
Since you did not commit, your .git never stored this information. So, basically git
cannot recover it for you.
But, If you just did git diff
, there is a way you can recover using the terminal output with the following 3 simple steps.
git diff
. Save the o/p in a file called diff.patchpatch -p1 < diff.patch
)You are saved! :)
Note : While you are copying the data from terminal to a file, be careful and clearly see that the data is continuous output and did not contain any redundant data(due to pressing up and down arrows). Otherwise you might mess it up.