gitrewrite
v0.1.0
Published
Edit Git history vidir style
Downloads
15
Maintainers
Readme
gitrewrite
Edit Git history vidir style.
Install
bun --global add gitrewrite
bunx gitrewrite
npm install -g gitrewrite
npx gitrewriteRequirements
gitand Node.js 18+- an attached branch head; detached
HEADis not supported
How It Works
gitrewriteselects a first-parent suffix ending atHEAD- writes that selection to a temporary
history.yaml - opens the YAML buffer in
$EDITOR gitrewritevalidates the edited YAML and prints a simulated rewrite- it prompts before applying unless you pass
--yesor--no-verify
Quick Start
gitrewrite
gitrewrite --last 5
gitrewrite --all
gitrewrite HEAD~10..HEAD
gitrewrite HEAD~10 --dry-run
gitrewrite --last 1 --yesBy default, gitrewrite selects the last 50 first-parent commits ending at HEAD.
Edited Buffer
The editor buffer is YAML. Each entry contains the commit identity and message fields that gitrewrite can rewrite:
- sha: 0123456789abcdef
subject: third
author:
name: Test User
email: [email protected]
committer:
name: Test User
email: [email protected]
date: 2026-02-22 01:23:45
body: |
bodyYou can:
- change
subject,body,author,committer, ordate - reorder entries to replay commits in a different order
- remove entries to drop commits from the selected range
Selection Rules
gitrewriteonly edits a contiguous first-parent suffix ending atHEAD--last Nand--allare mutually exclusive[revision]cannot be combined with--lastor--all- a single revision like
HEAD~10is treated asHEAD~10..HEAD
Flags
--last Nedit the lastNfirst-parent commits ending atHEAD--alledit the full first-parent history ending atHEAD--dry-runpreview the rewrite without applying it--no-verifyskip the confirmation prompt after validation--yesapply without the confirmation prompt
Notes
- Reordering or dropping merge commits is not supported. Merge commits can still be edited for metadata changes.
- If the edited YAML is semantically unchanged,
gitrewriteexits cleanly without rewriting history. - If the working tree is dirty,
gitrewritepreserves those tracked changes and updates the branch ref without checking out the rewritten tree. - Rewritten history still needs the usual force-push workflow if you have already published those commits.
Safer Workflow
Use --dry-run first when you are changing commit order or dropping commits:
gitrewrite --last 5 --dry-runThat prints the planned changes, the Git operations, and the simulated selected history without mutating the branch.
