xxxxxxxxxx
# To go back one commit and update the branch pointer
git checkout HEAD~1
# If you want to keep the changes made in the current commit
git stash
# To go back one commit and discard the changes made in the current commit
git reset HEAD~1
xxxxxxxxxx
git revert HEAD~3 # revert back 3 commits
git restore # to restore files from commit
xxxxxxxxxx
# Go back to the selected commit on your local environment
# Don't forget the . in the end
git checkout <commit-id> .
# Add this version to the staging area and push to remote
git add .
git commit -m "Reverting to <commit-id>"
git push
xxxxxxxxxx
// The '.' is needed to attached HEAD!
$ git checkout <commit_id> .
$ git add .
$ git commit -m "go back to <commit-id>"
$ git push
// checkout source for full details!
xxxxxxxxxx
#You need to be careful with going back a commit, you could reset your
#branch and loose all of your work.
#safe option:
git checkout <commit-id>