varunkr
varunkr

Reputation: 5542

Git: Accidentally reverted without commiting

Hey I am in deep trouble it looks. So I was going to commit my files in Android Studio using the GUI and I accidentally pressed the revert button. My last commit was made 4-5 days back, I know it is a bad practice and I should have made more commits. But I am back to where I was on May 23 and I don't know how I can go back to my previous state, which in fact wasn't even committed. Am I screwed here? Is there any hope? Please help guys !!

Upvotes: 5

Views: 1768

Answers (1)

gogstad
gogstad

Reputation: 3739

Yes. Git doesn't know about changes to your local file system until you commit them. Some IDEs keep a log of local changes (IntelliJ does this for instance), so I believe that's you best shot. Press the shortcut for undo, and see what happens, or look for "Local history" in the menus.

For IntelliJ: Select the root project, right click and choose "Show Local History". You should see a "commit" to your local history containing deletion of all your files. Revert this.

If you had commited your changes, you would have been able to locate the commit in the commit tree, or be reviewing git reflog.

Upvotes: 10

Related Questions