checkout previous commit in git code example
Example 1: 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 2: git checkout commit
git checkout <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
Example 5: git checkout previous commit
$ git reset --hard <commit_id>