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

16 lines
388 B
Markdown
Raw Normal View History

# Fixing commits
```bash
# Revert the last commit.
git revert HEAD
2018-02-08 18:25:03 +00:00
# Revert only the second to last commit. Etcetera
git revert HEAD~1
2018-02-08 18:25:03 +00:00
# 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>
```