# git absorb

> Git subcommand that automatically creates fixup! commits from staged changes by finding the commit each hunk belongs to, with optional autosquash rebase.

Stars: 5.8k · Language: Rust · License: BSD-3-Clause · Categories: Git

- Repository: https://github.com/tummychow/git-absorb
- Website: https://crates.io/crates/git-absorb
- Page: https://www.trmn.sh/tools/git-absorb

## Install

- Homebrew: `brew install git-absorb`
- apt (Debian/Ubuntu): `apt install git-absorb`
- Cargo: `cargo install git-absorb`

## Overview

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

```bash
# via Homebrew
brew install git-absorb
```

```bash
# via apt (Debian/Ubuntu)
apt install git-absorb
```

```bash
# via Cargo
cargo install git-absorb
```

## Alternatives

- [gitu](https://www.trmn.sh/tools/gitu.md): Terminal user interface for Git inspired by Magit, providing visual staging, branching, and repository management (Rust, 2.9k stars)
- [serie](https://www.trmn.sh/tools/serie.md): Terminal UI for git commit graphs using image protocols to render rich visualizations in supported terminals (Rust, 2.2k stars)
- [lazyjj](https://www.trmn.sh/tools/lazyjj.md): Terminal UI for Jujutsu version control system, providing interactive log browsing, file management, and bookmark operations (Rust, 1.2k stars)
- [gitnr](https://www.trmn.sh/tools/gitnr.md): Cross-platform CLI tool for creating .gitignore files from GitHub and TopTal template collections (Rust, 239 stars)
- [ftdv](https://www.trmn.sh/tools/ftdv.md): Terminal-based diff viewer for Git with interactive file tree navigation and configurable external diff tool support. (Rust, 72 stars)

---

Canonical: https://www.trmn.sh/tools/git-absorb
