git absorb
Git subcommand that automatically creates fixup! commits from staged changes by finding the commit each hunk belongs to, with optional autosquash rebase.
git absorb is a Git subcommand, ported from Facebook's hg absorb, that takes staged changes and turns them into fixup! commits targeting the earlier commits they belong to. It removes the need to look up commit SHAs for git commit --fixup or to build an interactive rebase by hand. A typical use is applying code review feedback to a feature branch while keeping atomic commits.
The workflow is git add the files you changed, then run git absorb. Only content in the index is considered. Each resulting fixup! commit message names the target commit's message (if unique) or its SHA. With --and-rebase, the fixups are folded into their targets automatically. Otherwise you can inspect them with git log and run git rebase -i --autosquash. GIT_SEQUENCE_EDITOR can be set to skip editing the rebase TODO. If the result is wrong, git reset --soft PRE_ABSORB_HEAD restores the pre-absorb state.
To pick a target, git absorb checks whether each staged hunk commutes with each commit, starting from HEAD and going backward. The first commit that does not commute with the hunk is taken as its parent. Hunks that commute with every commit in range stay staged and a warning is shown. By default the last 10 commits are considered, and --base <ref> sets the first commit explicitly.
It is written in Rust and uses a statically linked libgit2 rather than the system one. Release binaries are provided for Windows, macOS and Linux. It is aimed at developers who maintain clean commit histories on feature branches.
Installation
# via Homebrew
brew install git-absorb
# via apt (Debian/Ubuntu)
apt install git-absorb
# via Cargo
cargo install git-absorb
Alternatives & related tools
gitu
Terminal user interface for Git inspired by Magit, providing visual staging, branching, and repository management
serie
Terminal UI for git commit graphs using image protocols to render rich visualizations in supported terminals
lazyjj
Terminal UI for Jujutsu version control system, providing interactive log browsing, file management, and bookmark operations
gitnr
Cross-platform CLI tool for creating .gitignore files from GitHub and TopTal template collections
ftdv
Terminal-based diff viewer for Git with interactive file tree navigation and configurable external diff tool support.
add a badge to your README
Maintain git absorb? Show that it's featured on trmn. The badge links back to this page.
[](https://www.trmn.sh/tools/git-absorb?utm_source=badge)<a href="https://www.trmn.sh/tools/git-absorb?utm_source=badge"><img src="https://www.trmn.sh/badge/git-absorb.svg" alt="Featured on trmn" height="20"></a>