git absorb: Auto-Fixup Commits Into a Stack
git absorb figures out which earlier commit each staged hunk belongs to and creates matching fixup! commits automatically.
When you address review feedback across several commits, git absorb saves the manual fixup dance: it maps staged hunks to the commits that introduced those lines and stages the fixups for you.
What it does
git absorb inspects the staged changes, finds the most recent commit that touched each affected line, and creates a fixup! commit targeting it. With --and-rebase it immediately runs an autosquash rebase so the fixups fold in.
Common usage
# stage the review fixes, then absorb them into their commits
git add -u
git absorb --and-rebase
# limit how far back absorb will search
git absorb --base mainOptions
| Flag | What it does |
|---|---|
| --and-rebase / -r | Run an autosquash rebase after creating fixups |
| --base <ref> | Only consider commits reachable after this ref |
| --force / -f | Absorb even into commits older than the default window |
| --dry-run / -n | Show what would be absorbed without committing |
In CI
git absorb is mostly a local tool, but in automated cleanup jobs pass --base so it does not try to rewrite commits before the branch point, and --and-rebase to complete the squash in one step. It needs staged changes; unstaged hunks are ignored.
Common errors in CI
"nothing to absorb" means no changes are staged (run git add first) or absorb could not match hunks to a commit within its search window; widen it with --base or --force. "could not find a commit to fixup" is the same cause. A rebase started by --and-rebase can conflict and stop, leaving a rebase in progress.