book-git-commands/src/commits/fixing.md

388 B

Fixing commits

# Revert the last commit.
git revert HEAD

# Revert only the second to last commit. Etcetera
git revert HEAD~1

# Revert the last three commits, but stage the reversion locally.
git revert --no-commit HEAD~3..

# Reset working files to match master (or another branch), removing local changes and commits.
git fetch --all
git reset --hard origin/<branchName>