undo commit
# KEEP CHANGES
git reset --soft HEAD~1
# REMOVE CHANGES
git reset --hard HEAD~1
Lively Leopard
# KEEP CHANGES
git reset --soft HEAD~1
# REMOVE CHANGES
git reset --hard HEAD~1
git reset --soft HEAD~
git reset --hard HEAD~1
git push -f <remote> <branch>
git reset --hard <last_working_commit_id>
git push --force
git reset --hard <last_working_commit_id>
So we must not reset to the commit_id that we don't want.
Then sure, we must push to remote branch:
git push --force
git reset --hard 'xxxxx'
git clean -f -d
git push -f