git test previous commit code example
Example 1: git check previous commit
$ git log
commit ca82a6dff817ec66f44342007202690a93763949
Author: Scott Chacon <[email protected]>
Date: Mon Mar 17 21:52:11 2008 -0700
Change version number
commit 085bb3bcb608e1e8451d4b2432f8ecbe6306e7e7
Author: Scott Chacon <[email protected]>
Date: Sat Mar 15 16:40:33 2008 -0700
Remove unnecessary test
commit a11bef06a3f659402fe7563abf99ad00de2209e6
Author: Scott Chacon <[email protected]>
Date: Sat Mar 15 10:31:28 2008 -0700
Initial commit
Example 2: after checking out a previous commit go back to latest commit
git checkout <commit hash> # go to previous commit
git revert <commit hash> # revert action of going to previous commit
Example 3: git checkout previous commit
git reset --hard HEAD~10
To rollback 10 commits back:
Example 4: git pull from previous commit
git checkout -b old-state 0d1d7fc32