Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git how to move back commit

Tags:

git

git-bash

I want to go back a committed one. How can I do?

$ git reflog
9b2a45e HEAD@{0}: reset: moving to HEAD~1
0c54f19 HEAD@{1}: reset: moving to HEAD~1
b9c157d HEAD@{2}: commit: updated from online
0c54f19 HEAD@{3}: commit: add img from download folder
9b2a45e HEAD@{4}: commit: add images
6fa6e34 HEAD@{5}: clone: from [email protected]:starpix/dojo.git


$ git reset --hard HEAD~1
HEAD is now at 9b2a45e add images

I want to go back to "updated from online". how can I?

like image 452
Thu Ra Avatar asked Aug 23 '12 04:08

Thu Ra


3 Answers

you can just move head forword to b9c157d

git reset --hard b9c157d
like image 132
Ted Shaw Avatar answered Sep 19 '22 02:09

Ted Shaw


git checkout b9c157d checks out the commit represented by the sha starting with b9c157d -- the commit you asked about.

like image 33
Mark Rushakoff Avatar answered Sep 20 '22 02:09

Mark Rushakoff


If you have the commit id of that particular commit then this syntax will do for you.

git checkout commit_name in the commit name pass the commit id and if you don't want to checkout again then to revert the commit will do by this one git revert commit_name.

like image 38
Prateek Avatar answered Sep 19 '22 02:09

Prateek