absorb
Absorb staged changes into the appropriate commits in your stack. This analyzes staged hunks and automatically creates fixup commits targeting the commits that last modified those lines.
Usage
rung absorbrung absorb --dry-runrung absorb --base mainAliases
rung ab— shorthand forrung absorb
Options
| Option | Description |
|---|---|
--dry-run | Show what would be absorbed without making changes |
-b, --base <branch> | Base branch to determine rebaseable range (auto-detected from GitHub by default) |
How It Works
When you run rung absorb:
- Parse — Parses your staged diff into hunks
- Blame — Uses
git blameto find which commit last modified each hunk’s lines - Validate — Checks the target commit is in your stack (not already on the base branch)
- Fixup — Creates
fixup!commits targeting the appropriate commits
Example
# Make some tweaks to existing codevim src/auth.rs
# Stage the changesgit add -p
# Preview what would be absorbed$ rung absorb --dry-run→ 2 hunk(s) will be absorbed: a1b2c3d4 Add authentication middleware (2 hunk(s)) → src/auth.rs → src/auth.rs→ Dry run - no changes made
# Actually absorb the changes$ rung absorb→ 2 hunk(s) will be absorbed: a1b2c3d4 Add authentication middleware (2 hunk(s)) → src/auth.rs → src/auth.rs✓ Created 1 fixup commit(s)→ Run `git rebase -i --autosquash` to apply the fixupsApplying Fixups
After absorb creates fixup commits, apply them with an interactive rebase:
# Use the same base branch as the absorb commandgit rebase -i --autosquash mainGit will automatically reorder the fixup commits to follow their targets.
Workflow Example
# You're working on a feature branch with several commits$ rung loga1b2c3d Add user authentication youe4f5g6h Add auth middleware youi7j8k9l Add auth tests you
# You notice a small bug in the middlewarevim src/middleware.rs
# Stage just that fixgit add -p src/middleware.rs
# Absorb it into the right commit$ rung absorb→ 1 hunk(s) will be absorbed: e4f5g6h Add auth middleware (1 hunk(s)) → src/middleware.rs✓ Created 1 fixup commit(s)→ Run `git rebase -i --autosquash` to apply the fixups
# Now apply the fixupgit rebase -i --autosquash mainUnmapped Hunks
Some hunks cannot be absorbed. Rung reports these with reasons:
$ rung absorb! 2 hunk(s) could not be absorbed: src/new_file.rs (new file) src/mixed.rs (multiple commits touched these lines)
→ 1 hunk(s) will be absorbed: a1b2c3d4 Fix validation (1 hunk(s)) → src/auth.rsReasons for Unmapped Hunks
| Reason | Description |
|---|---|
| new file | New files have no blame history |
| multiple commits touched these lines | The changed lines were last modified by different commits |
| target commit not in stack | The blamed commit is not between base and HEAD |
| target commit already on base branch | The blamed commit is already merged |
| blame error | Git blame failed for this file/range |
Limitations
- New files cannot be absorbed (no blame history exists)
- Multi-commit hunks — If a hunk touches lines from multiple commits, it cannot be automatically assigned
- Single target only — All staged hunks must target the same commit; stage fewer changes if they target different commits
- Rebaseable range — Only works with commits between the base branch and HEAD
Base Branch Detection
By default, rung queries GitHub to detect the default branch. You can override this:
# Explicit base branchrung absorb --base develop
# Required if GitHub auth is unavailablerung absorb --base mainUse the same base branch when running git rebase --autosquash.
Notes
- Stage changes with
git add -pfor fine-grained control over what gets absorbed - Use
--dry-runto preview before creating fixup commits - The base branch for absorb and the subsequent rebase should match
- Works best with small, focused fixes that clearly belong to specific commits