Maintaining a clean, linear Git commit history during active feature development or code review iterations often involves manual interactive rebasing. When reviewers spot a typo, an unhandled null check, or a formatting inconsistency across earlier commits, developers typically create a new patch, run git log to find the matching commit SHA, execute git commit --fixup <sha>, and finally run git rebase -i --autosquash. git-absorb, written in Rust, automates this tedious workflow by inspecting your staged modifications, using git blame heuristics to identify which earlier commit introduced each changed line, and generating matching fixup commits automatically.
Why Incorporate git-absorb into Your Workflow?
Manual fixup attribution is slow and error-prone, especially when your working branch contains dozens of discrete commits. Key benefits of git-absorb include:
- Automated Commit Mapping: Analyzes modified hunks and matches them with their origin commits without manual SHA lookups.
- Multi-Commit Dispersal: If your staged changes touch five lines originating from three different earlier commits,
git-absorbsplits and assigns them into three separate fixup commits automatically. - Safety Verifications: Skips ambiguous hunks that modify newly added code or overlap conflicting commits, preventing accidental rebase conflicts.
- Zero-Friction Autosquashing: Works seamlessly with
git rebase -i --autosquashto absorb fixes into target commits silently.
Installing git-absorb Across Linux Distributions
The git-absorb utility is widely available across package managers.
Installing on Arch Linux and Manjaro
sudo pacman -S git-absorb
Installing on Ubuntu, Debian, and Mint via Cargo
Ensure you have Rust and Cargo installed, then compile the native crate:
cargo install git-absorb
Downloading Standalone Binaries
Download pre-compiled binaries from the GitHub releases repository:
# Download latest release archive
wget https://github.com/tummychow/git-absorb/releases/latest/download/git-absorb-x86_64-unknown-linux-musl.tar.gz
# Extract and install into system PATH
tar -xvf git-absorb-x86_64-unknown-linux-musl.tar.gz
sudo mv git-absorb /usr/local/bin/
chmod +x /usr/local/bin/git-absorb
Step-by-Step: Using git-absorb in Daily Development
To fold bug fixes or review corrections into earlier branch commits:
- Make your bug fixes or code review adjustments across local project files.
- Stage the modified changes using standard Git commands:
git add -u
- Perform a dry run to inspect how
git-absorbmaps each change:
git absorb --dry-run
Output shows which commit SHA each modified line will be assigned to.
- Execute the absorption command:
git absorb
git-absorb creates dedicated fixup! commits targeting each respective ancestor commit.
- Squash the fixup commits cleanly into the history:
git rebase -i --autosquash origin/main
Git automatically applies every fixup commit directly into its target commit and leaves you with a pristine, linear branch history ready for merging.
Advanced Flags and Customisation
| Flag | Function and Behaviour |
|---|---|
-n, --dry-run |
Simulates absorption and reports commit pairings without modifying git state. |
-r, --base <ref> |
Restricts commit inspection depth to a specific base branch (e.g. main). |
-v, --verbose |
Outputs detailed blame tracing information for each parsed hunk. |
--and-rebase |
Automatically triggers git rebase -i --autosquash immediately after creating fixups. |
Adopting git-absorb eliminates the friction of code review rebasing, allowing developers to focus on writing correct code rather than tracking commit SHAs.