Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to revert project back to a previous commit in android studio

I am working on a project in android studio and would like to revert to a previous push. I attempted
VCS => Git => Reset Head (Hard)
but my project in Android Studio is unchanged, likely because I'm doing something wrong. I would like to revert the project in Android Studio to a specific earlier commit that I've pushed and I see on github. I do not care about any changes that I have made since the earlier push.
Additionally, I would like this to be done through the GUI within Android Studio if possible.

like image 691
aisflat439 Avatar asked Jul 02 '16 18:07

aisflat439


People also ask

How do I rollback a project in Android Studio?

Switch to Project in the left part of Android Studio, right-click the application name on top, click Local History , click Show History . Then find the revision you want back, right click it and choose Revert . Your whole project will be reverted to this state.


2 Answers

Android Studio Instructions: if you want to do this in Android Studio, press alt + 9 (or Command + 9 on Mac) to open the Version Control panel. Switch to the Log tab and right click on a previous commit. Select Checkout Revision.


Command line instructions: Open the command line tool you are using. Go to the Android app's Git directory (using cd). Execute git log and find the previous commit you want to revert to.

commit 7c247be6d8975dc88f6cc2631c154786a1f3b79e Author: John Doe <[email protected]> Date:   Fri Jun 11 22:37:35 2015 -0400      Some helpful commit message should be here. 

If that is the commit you want to revert to, then execute git checkout 7c247b.

like image 187
player87 Avatar answered Sep 21 '22 09:09

player87


Open the Version Control Panel using alt + 9 and click on Log. This should show a list of commits. Right click on the commit you want to revert to and select Reset Current Branch to Here. This should bring up a list of options to keep or discard changes when reverting. Select Hard to discard any current changes and click Reset.

like image 38
J. Jefferson Avatar answered Sep 18 '22 09:09

J. Jefferson