How to Install and Use git-absorb in Linux for Automatic Git Fixup Commits

When working on feature branches with Git, developers often create a logical sequence of commits (e.g., initial schema design, service implementation, API endpoints, unit tests). As you test and review your code, you inevitably discover minor bugs, missing semicolons, or formatting errors in earlier commits. Manually running git log to find the matching commit hash, executing git commit --fixup [HASH], and running an interactive rebase with autosquash is tedious. git-absorb is a powerful, automated Git extension written in Rust that analyses your uncommitted diffs, identifies which branch commit introduced each modified line, and generates targeted fixup commits automatically.

How git-absorb Revolutionises Branch Maintenance

Traditional Git workflows force developers to choose between sloppy “fix typo” commit clutter or manual rebase micromanagement. git-absorb delivers the best of both worlds:

  • Heuristic Blame Analysis: Uses an enhanced git blame algorithm against your active working tree or staged index to identify the exact historical commits where modified lines originated.
  • Automated Fixup Generation: Automatically generates fixup! [commit message] commits for each matching changeset without manual intervention.
  • Safe Branch Boundaries: Never modifies commits beyond your branch base or unpushed upstream references, safeguarding master and main branches against inadvertent alteration.
  • Autosquash Compatibility: Works hand-in-hand with git rebase -i --autosquash, folding changes seamlessly into their rightful commits.

Step 1: Installing git-absorb on Linux

git-absorb is available across major Linux distributions through package managers, pre-compiled binaries, and Cargo.

Option A: Install via Native Repositories

On Arch Linux and its derivatives:

sudo pacman -S git-absorb

On Alpine Linux:

sudo apk add git-absorb

Option B: Install via Pre-Compiled GitHub Release

For Ubuntu, Debian, Fedora, openSUSE, and enterprise environments, download the official standalone binary:

# Download latest binary release
curl -LO https://github.com/troyhinckley/git-absorb/releases/latest/download/git-absorb-x86_64-unknown-linux-musl.tar.gz

# Extract binary archive
tar -xzf git-absorb-*-linux-musl.tar.gz

# Move binary to executable path
sudo mv git-absorb /usr/local/bin/
chmod +x /usr/local/bin/git-absorb

Option C: Install via Rust Cargo

If you maintain a local Rust toolchain:

cargo install git-absorb

Verify installation by inspecting the version:

git absorb --version

Step 2: Practical Usage Example in a Feature Branch

Suppose you are working on a feature branch containing three commits:

  1. Commit A: Add User authentication model
  2. Commit B: Implement JWT token verification
  3. Commit C: Add authentication integration tests

While testing, you notice a typo inside the authentication model file (user.rs) and an off-by-one error in your test suite (test_auth.rs). You fix both files in your editor.

Dry-Run Inspection

Before modifying Git history, preview how git-absorb intends to allocate your changes:

git absorb --dry-run

git-absorb outputs its mapping decision:

user.rs: will absorb into Commit A (Add User authentication model)
test_auth.rs: will absorb into Commit C (Add authentication integration tests)

Executing the Absorb

To generate the fixup commits automatically:

git absorb

git-absorb commits the modifications, producing two separate fixup! commits paired with their respective ancestor hashes.

Step 3: Folding Fixup Commits with Autosquash Rebase

Once git-absorb creates the fixup commits, fold them cleanly into your branch history using interactive rebase with the autosquash flag:

git rebase -i --autosquash origin/main

Git automatically groups each fixup commit directly beneath its parent and marks it with the fixup action. Save and close the editor. Your branch history is now pristine, with every bug fix seamlessly integrated into its original commit as if the error never occurred.

Step 4: Automating Autosquash in Git Configuration

To eliminate the need to type --autosquash on every rebase invocation, enable it globally in your Git configuration:

git config --global rebase.autoSquash true

Now, whenever you run a standard interactive rebase (git rebase -i HEAD~5), Git detects fixup commits generated by git-absorb and arranges them automatically.

Step 5: Useful Flags and Options

  • git absorb -v (Verbose Mode): Provides detailed logging explaining why certain hunks were matched to specific commits.
  • git absorb -r [BASE] (Custom Base): Limits absorption to commits after a specified commit reference or branch (e.g., git absorb -r HEAD~10).
  • git absorb -a (Auto-Stage): Stages all modified files automatically before running the absorb analysis, saving you from typing git add -u beforehand.

Streamlining Clean Git Histories

Integrating git-absorb into your Linux development workflow transforms branch housekeeping from a chore into a zero-effort background task. By eliminating manual fixup commit hunting, you maintain spotless, reviewer-friendly Git pull requests with minimal cognitive overhead.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.