git checkout to previous commit code example
Example 1: after checking out a previous commit go back to latest commit
git checkout <commit hash>
git revert <commit hash>
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: checkout master with previous commit
git checkout 307a5cd
git checkout -b fixy
git merge -s ours master
git checkout master
git merge fixy
git push
Example 6: git checkout previous commit HEAD
git checkout <commit-id>
git checkout -b <branch name>