i reset my head to a few commits back in android studio and chose reset type as hard. I lost a weeks work. Is there any hope to undo this ? I am using android studio and it has GUI built in options to do all git related functions so i never used git bash (or whatever terminal is used for git). There is a solution here but it used terminal so i asked again if anyone knows how to do it using android studio itself.
Asked
Active
Viewed 2,517 times
2
-
2`git reflog` is your friend. – 1615903 Jan 18 '16 at 10:13
-
@1615903 im using android studio. Is there a GUI button or something or do i need to use git bash? That ans does not say if android studio has GUI to do it so i asked again. I have never used git bash – Shreyans Jan 18 '16 at 10:17
-
Read this out: http://stackoverflow.com/questions/34519665/how-to-move-head-checkout-revet-reflog-reset/34519716#34519716 – CodeWizard Jan 18 '16 at 10:17
-
@Shreyans I see - retracted my close vote. – 1615903 Jan 18 '16 at 10:21
2 Answers
20
It's likely that you can use Android Studio's Local History to restore the changes. Right click the root directory of your project, select Local History | Show History... from the menu. In the history, you'll find an "External change" entry corresponding to the 'git reset' command that you performed. You can select the entry below that and press the "Revert" button.

yole
- 92,896
- 20
- 260
- 197
0
Read the full answer here - How to move HEAD (checkout, revet, reflog, reset):
Summary of the attached answer
(read it through to get a very detailed answer):
git checkout
git checkout <commit_id>
git reflog
You can always use the reflog
as well
git reflog
git checkout HEAD@{...}
This will get you back to your desired commit
git reset HEAD --hard <commit_id>
"Move" your head back to the desired commit.
# This will destroy any local modifications.
# Don't do it if you have uncommitted work you want to keep.
git reset --hard <sha-1>
git checkout
git checkout -b <new branch> <commit_id>
git checkout HEAD~X // x is the number of commits t go back
This will checkout new branch pointing to the desired commit

Community
- 1
- 1

CodeWizard
- 128,036
- 21
- 144
- 167
-
1thanks for a very detailed and informative answer !! I know this took more effort than the accepted answer but considering the noob i am with git bash i wanted a solution that could use android studios GUI so i accepted the other answer – Shreyans Jan 18 '16 at 10:50
-