Git commands to remove latest commit

Updated: 12th April 2021
Tags: git

Remove commit but save current code

git reset --soft HEAD~1
git push origin master --force

Remove commit and remove commit’s code

git reset --hard HEAD~1
git push origin master --force