In this chapterChoose the right way to edit or recover commit history.
Review history
Choose an action
Keep a way back
Everything here can be undone with Undo. GitTrail warns before rewriting commits that are already pushed or already in main.
- History editor (interactive rebase): drag commits to reorder; squash, fixup, reword, drop or split them. No text editor needed.
- Squash by dropping one commit on another.
- Fixup commits: make
fixup!commits, then squash them all. - Move files or hunks out of a commit.
- Cherry-pick onto several branches in one go.
- Reset: soft, mixed, hard, or keep (your uncommitted work stays).
- Revert one or several commits.
- Reflog: see every move of HEAD and branches; recover lost commits.
- Bisect: find the commit that broke something, step by step, or let a test command decide.
- Clean up history: find the biggest files in history and remove files or secrets from every commit, with a backup.
Need another approach?Find a fix →