Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 !!

like image 440
varunkr Avatar asked May 26 '16 20:05

varunkr


1 Answers

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.

like image 198
gogstad Avatar answered Sep 19 '22 18:09

gogstad