Search the field guide

Search all 29 chapters. Your search stays on this device.

↑ ↓ Move between results Enter Open · Esc Close

Browse chapters

DocsEveryday GitFIELD NOTES / 15

Everyday Git · 1 min read

Editing history safely

Preview documentation About this guide ⓘ

GitTrail is in preview: commands and features may change before the first release, and host integrations are still being tested against each live service.

Chapter 15 of 29
On this page

In this chapterChoose the right way to edit or recover commit history.

Know the change before you rewrite 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 →