History rewriting safely
Choose the right rewrite command and understand how to recover or publish the result.
Warning: Rewriting history changes commit IDs. Coordinate with collaborators before rewriting shared branches, and expect to force-push afterward.
Choose a command
| Goal | Command | Can Git Wrangler roll it back? |
|---|---|---|
| Change author names or emails | rewrite-authors |
Yes |
| Add, replace, or remove coauthors | rewrite-coauthors |
Yes |
| Generate better commit messages with AI | rewrite-commits |
Yes |
| Redistribute commits across dates | rewrite-dates |
Yes |
| Move commits into daily working hours | rewrite-hours |
Yes |
| Permanently remove secret files | remove-secrets |
No |
| Restore supported Git Wrangler rewrites | rollback-rewrites |
— |
Before rewriting
- Commit or stash current work.
- Make sure collaborators know the branch history will change.
- Run the command without
--yesand read the preview. - Keep a separate backup when the history is especially important.
Rewrite commands refresh origin before planning. Use --no-fetch only when offline or when you intentionally accept that remote information may be old.
How rollback works
Git Wrangler keeps the original state of commits changed by supported rewrite commands. Later supported rewrites extend the same recovery point, so one rollback-rewrites run restores the history from before those changes while keeping newer commits where possible.
remove-secrets is different. It clears earlier rewrite recovery data before removing files and does not create a new recovery point. This prevents a later rollback from bringing deleted secrets back.
After rewriting
Inspect the result locally, then publish it with lease protection:
git-wrangler log
git-wrangler push --force
Tags are not the main rewrite target, and commit or tag signatures may no longer be valid after history changes. Collaborators may need to reset or re-clone after the force push.
Date filters
Commands with --rewrite-after and --rewrite-before select commits using the author dates currently shown in history:
after <= selected commit < before
The start date is included and the end date is excluded.