0

I was making a project. Coding all day long and at the end of the day decided to push my code to repo. Git status in the directory was a mess, so I decided to move it to another one.

Then I found a solution on google, that says: "Do git reset --hard and everything will fix itself." So I've done. Then all my local files including the directory are missing. Can I restore it somehow?

Git reflog show only commits on branch and I did make one before reset.

yungstepik
  • 41
  • 5
  • 2
    Uncommitted changes are lost, as far as git is concerned. Maybe check on your IDE's part if it has recovery features, but if not, that's all. A full day without committing? That was the mistake. Commit often, commit early. – Romain Valeri Jun 05 '21 at 08:01
  • 1
    Also, blindly following "*a* solution on google" is a recipe for disaster. Did the author *explain* what it was supposed to achieve? Not to bash you over this, of course, but a bit more caution/curiosity would have saved the day... I hope you didn't lose too much. – Romain Valeri Jun 05 '21 at 08:11
  • 1
    As already mentioned in another comment, as far as Git is concerned, the changes are gone. However, there might be a chance that you have a "backup-service" running on your OS that made one or several snapshots during the day. If this is the case, it may be worth trying to recover something this way. E.g. Time Machine on MacOS does an hourly backup for the last 24h and probably would still contain parts of the changes. – Matt Jun 05 '21 at 08:13
  • 1
    If the files has been staged, there is a possibility. See [my answer and others that are good also on this problem](https://stackoverflow.com/questions/11094968/in-git-how-can-i-recover-a-staged-file-that-was-reverted-prior-to-committing/58853981#58853981). Otherwise the solution won't come from git but from your IDE, files deleted recovery tools,... – Philippe Jun 05 '21 at 09:00
  • https://stackoverflow.com/search?q=Recover+%5Bgit%5D+reset+hard – phd Jun 05 '21 at 10:30

0 Answers0