aisflat439
aisflat439

Reputation: 975

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.

Upvotes: 79

Views: 107179

Answers (10)

Mohammed Shahbaz
Mohammed Shahbaz

Reputation: 109

use the below command

git revert <hashString of the commit that you wanted to go on>

Upvotes: 0

Vahit Keskin
Vahit Keskin

Reputation: 438

While push is selected branch to undo; example brach name -> push_will_be_undone

git push -f origin push_will_be_undone

Writing did my job and it worked for me

Upvotes: 0

yoAlex5
yoAlex5

Reputation: 34195

MacOS users

Rollback Changes

⌘ Command + ⌥ Option + Z

VCS -> Git -> Rollback...
//or
VCS Local  Changes Toolbar -> Rollback...
//or
Commit Changes -> Rollback...

Upvotes: 0

minato
minato

Reputation: 2332

Android Studio > check bottom toolbar -> click on git -> select log tab -> right on particular commit -> reset current branch to here -> select hard reset

Also if u have already pushed code to server u need to run

git push -f origin branch_name

Upvotes: 6

VIVEK CHOUDHARY
VIVEK CHOUDHARY

Reputation: 546

  1. In android studio 4.0, go to version control -> Log.
  2. Then select the commit you want to revert to.
  3. Choose Reset current branch to here.
  4. You ll see a popup, select Hard and its done.

Upvotes: 11

player87
player87

Reputation: 1791

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.

Upvotes: 95

J. Jefferson
J. Jefferson

Reputation: 1010

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.

Upvotes: 32

wudizhuo
wudizhuo

Reputation: 1520

Android Studio -> Version Control -> Select your commit -> Right panel -> Select you want to be reverted file.

enter image description here

Then you can get the new reverted change, commit -> done.

Upvotes: 6

Sagar Jogadia
Sagar Jogadia

Reputation: 1350

The icon surrounded by red rectangle in image will do the trick

Upvotes: 20

user3486470
user3486470

Reputation: 296

Right click on folder where you Github folder, press Git Bash Here and type git reset --hard

Upvotes: -5

Related Questions