Is there any way to recover uncommitted changes to the working directory from a git reset --hard HEAD?
Is there any way to recover uncommitted changes to the working directory from a
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You cannot get back uncommitted changes in general.
Previously staged changes (
git add) should be recoverable from index objects, so if you did, usegit fsck --lost-foundto locate the objects related to it. (This writes the objects to the.git/lost-found/directory; from there you can usegit show <filename>to see the contents of each file.)If not, the answer here would be: look at your backup. Perhaps your editor/IDE stores temp copies under /tmp or C:\TEMP and things like that.[1]
This will restore to the previous HEAD
[1] vim e.g. optionally stores persistent undo, eclipse IDE stores local history; such features might save your a**