Reputation: 61
I accidentally did a git reset --hard origin
on my local repository. As a result, all of my changes have been reverted back to their original state, hence my months' worth of code and work is gone. I didn't do git add
on my repository so literally, any changes I've made on my repository are gone without a trace. I've tried searching for a solution but I've only seen answers that pertain that you can only recover your work if you do git add
to it.
Any help is greatly appreciated. PLEASE DO HELP ME, GUYS.
Upvotes: 2
Views: 1402
Reputation: 1323343
Beside running a file recovery utility, as detailed in "Can I restore deleted files (undo a git clean -fdx
)?", check your IDE.
Some of them keep a local history (IntelliJ IDEA, VSCode through an extension, ...): you might get back some of your files content that way.
But yes, regular add and commit, even for a work in progress, is a best practice.
A regular push to a remote "work-in-progress" branch is equally good, to save your work to an external referential.
Upvotes: 1