Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

absorb

Fold each uncommitted change into the commit that last touched the same lines.

Usage

git loom absorb [-n] [<files>...] [-- <git args>...]

Arguments

ArgumentDescription
<files>...File short IDs or paths to absorb (default: every changed tracked file)

Options

OptionDescription
-n, --dry-runShow where each change would go, without changing anything

Git Options

Arguments after -- go to the git commit behind each fixup, unchecked — expert mode, see Passing Options to Git:

git loom absorb -- --no-verify

What It Does

For each hunk, absorb finds the commit that last changed the lines it modifies or deletes, among the commits on your integration branch. Hunks of one file can go to different commits. All the fixups happen in one rewrite.

When a pre-commit hook fixes files and fails, absorb rolls back, the hook’s fixes included, and does not commit again: a formatter’s whole-file rewrite would land in one fixup, with lines other commits own. Run the formatter yourself first (e.g. pre-commit run --files <files>), then absorb: each fixed line goes to its own commit.

A hunk stays in the working tree when its target can’t be told:

  • it only adds lines, so there is nothing to trace back (use fold instead)
  • its lines come from several commits, or from upstream
  • the file is binary or new

Examples

Absorb all changes

git loom absorb
#   src/auth.rs -> a1b2c3d "Add authentication" (feature-auth)
#   src/shared.rs [hunk 1/2] -> a1b2c3d "Add authentication" (feature-auth)
#   src/shared.rs [hunk 2/2] -> d4e5f6a "Add dashboard" (feature-dashboard)
# ✓ Absorbed 3 hunk(s) from 2 file(s) into 2 commit(s)

Dry run

git loom absorb -n
#   src/auth.rs -> a1b2c3d "Add authentication" (feature-auth)
#   src/shared.rs -- skipped (pure addition)
# Dry run: would absorb 1 hunk(s) from 1 file(s) into 1 commit(s)

Restrict to some files

git loom absorb src/auth.rs src/utils.rs

Commits Already Upstream

If upstream already has everything a target commit changes, absorb refuses and leaves your changes in the working tree:

git loom absorb
# ✗ Commit `4783c1b` is redundant — the history below it already has its change
#   › Nothing was rewritten. Run `loom update` if it landed upstream

Conflicts

If the rewrite conflicts, absorb pauses:

git loom absorb
# ! Conflicts detected — resolve them with git, then run:
#   › loom continue   to complete the absorb
#   › loom abort      to cancel and restore original state
git add <resolved-files> && git loom continue
# ✓ Absorbed 1 hunk(s) from 1 file(s) into 1 commit(s)

See continue and abort.

Prerequisites

  • On an integration branch with uncommitted changes