只处理已 git add 进暂存区的内容,未暂存的改动不会被吸收;用 cargo install 安装时不会装 manpage,git absorb --help 无法使用;默认只考虑最近 10 个提交,更早的提交需用 --base 指定
brew install git-absorb
cargo install git-absorbREADME 未说明,纯命令行工具,无 GPU 或显存要求
自动把暂存区改动折叠进对应的历史提交,省去手动 fixup 和交互式 rebase
自动把工作区改动生成 git commit --fixup 提交,省去手动指定目标提交的麻烦,让 rebase 整理历史更顺手。
核心能力
- 按补丁是否可交换判断改动归属哪个提交
- 为每处改动自动生成 fixup! 提交
- 用 --and-rebase 直接完成 autosquash 合并
- 默认只回溯最近 10 个提交,可用 --base 指定范围
- 无法归属的改动保留在暂存区并给出警告
容易踩的坑
- 0.9.0最新正式版2026-02-14 · 2026-02-14 03:44 UTC
What's Changed
Other Changes
- and_rebase: use workdir() rather than .path().parent() by @Pear0 in https://github.com/tummychow/git-absorb/pull/191
- Extract structs that encode announcements to users by @blairconrad in https://github.com/tummychow/git-absorb/pull/194
- Add flag to create squash commits by @blairconrad in https://github.com/tummychow/git-absorb/pull/195
- Make output more human-readable by @blairconrad in https://github.com/tummychow/git-absorb/pull/200
- ci: add darwin arm64 (aarch64-apple-darwin) build target by @radiosilence in https://github.com/tummychow/git-absorb/pull/203
- Add --no-limit option by @p1k0chu in https://github.com/tummychow/git-absorb/pull/204
- Refrain from compiling debug-level messages out of release build by @blairconrad in https://github.com/tummychow/git-absorb/pull/208
New Contributors
- @Pear0 made their first contribution in https://github.com/tummychow/git-absorb/pull/191
- @radiosilence made their first contribution in https://github.com/tummychow/git-absorb/pull/203
- @p1k0chu made their first contribution in https://github.com/tummychow/git-absorb/pull/204
Full Changelog: https://github.com/tummychow/git-absorb/compare/0.8.0...0.9.0
- 0.8.02025-04-24 · 2025-04-24 01:53 UTC
查看更新说明
What's Changed
Other Changes
- Generate release notes by @blairconrad in https://github.com/tummychow/git-absorb/pull/161
- Init test repo with explicit branch by @sh-at-cs in https://github.com/tummychow/git-absorb/pull/165
- Quell warnings by removing unused Struct fields by @blairconrad in https://github.com/tummychow/git-absorb/pull/166
- Quell Waiting for your editor to close the file... hint by @blairconrad in https://github.com/tummychow/git-absorb/pull/167
- build: fix building manpages on systems where asciidoc is already installed by @eli-schwartz in https://github.com/tummychow/git-absorb/pull/169
- Mark pre-absorb commit with PRE_ABSORB_HEAD ref by @sh-at-cs in https://github.com/tummychow/git-absorb/pull/168
- issue #129 - Adds new -m option for adding commit message body to generated fixups by @arielf212 in https://github.com/tummychow/git-absorb/pull/176
- Uses lto in profile release (build --release and install) by @arielf212 in https://github.com/tummychow/git-absorb/pull/178
- Fixes basic clippy lints and runs clippy in the CI by @arielf212 in https://github.com/tummychow/git-absorb/pull/181
- Characterize user-facing log messages by @blairconrad in https://github.com/tummychow/git-absorb/pull/175
- Overhaul user-facing messages by @blairconrad in https://github.com/tummychow/git-absorb/pull/182
- Tell user how to rebase by @blairconrad in https://github.com/tummychow/git-absorb/pull/183
- Link to STACK SIZE docs instead of (removed) Configuration section by @blairconrad in https://github.com/tummychow/git-absorb/pull/186
- Generate HTML documentation by @blairconrad in https://github.com/tummychow/git-absorb/pull/185
New Contributors
- @sh-at-cs made their first contribution in https://github.com/tummychow/git-absorb/pull/165
- @eli-schwartz made their first contribution in https://github.com/tummychow/git-absorb/pull/169
- @arielf212 made their first contribution in https://github.com/tummychow/git-absorb/pull/176
Full Changelog: https://github.com/tummychow/git-absorb/compare/0.7.0...0.8.0
- 0.7.02025-03-09 · 2025-03-09 20:05 UTC
这个版本没有写更新说明。
- 0.6.172025-01-10 · 2025-01-10 00:40 UTC
这个版本没有写更新说明。
- 0.6.162024-11-03 · 2024-11-03 18:36 UTC
这个版本没有写更新说明。
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
git absorb
This is a port of Facebook's hg absorb, which I first read about on mozilla.dev.version-control:
- Facebook demoed
hg absorbwhich is probably the coolest workflow enhancement I've seen to version control in years. Essentially, when your working directory has uncommitted changes on top of draft changesets, you can runhg absorband the uncommitted modifications are automagically folded ("absorbed") into the appropriate draft ancestor changesets. This is essentially doinghg histedit+ "roll" actions without having to make a commit or manually make history modification rules. The command essentially looks at the lines that were modified, finds a changeset modifying those lines, and amends that changeset to include your uncommitted changes. If the changes can't be made without conflicts, they remain uncommitted. This workflow is insanely useful for things like applying review feedback. You just make file changes, runhg absorband the mapping of changes to commits sorts itself out. It is magical.
Elevator Pitch
You have a feature branch with a few commits. Your teammate reviewed the branch and pointed out a few bugs. You have fixes for the bugs, but you don't want to shove them all into an opaque commit that says fixes, because you believe in atomic commits. Instead of manually finding commit SHAs for git commit --fixup, or running a manual interactive rebase, do this:
git add $FILES_YOU_FIXED
git absorb --and-rebase
git absorb will automatically identify which commits are safe to modify, and which staged changes belong to each of those commits. It will then write fixup! commits for each of those changes.
With the --and-rebase flag, these fixup commits will be automatically integrated into the corresponding ones. Alternatively, you can check its output manually if you don't trust it, and then fold the fixups into your feature branch with git's built-in autosquash functionality:
git add $FILES_YOU_FIXED
git absorb
git log # check the auto-generated fixup commits
git rebase -i --autosquash master
Installing
The easiest way to install git absorb is to download an artifact from the latest tagged release. Artifacts are available for Windows, MacOS, and Linux (built on Ubuntu with statically linked libgit2). If you need a commit that hasn't been released yet, check the latest CI artifact or file an issue.
Alternatively, git absorb is available in the following system package managers:
| Repository | Command |
|---|---|
| Arch Linux | pacman -S git-absorb |
| Debian | apt install git-absorb |
| DPorts | pkg install git-absorb |
| Fedora | dnf install git-absorb |
| Flox | flox install git-absorb |
| FreeBSD Ports | pkg install git-absorb |
| Homebrew and Linuxbrew | brew install git-absorb |
| MacPorts | sudo port install git-absorb |
| nixpkgs stable and unstable | nix-env -iA nixpkgs.git-absorb |
| openSUSE | zypper install git-absorb |
| Ubuntu | apt install git-absorb |
| Void Linux | xbps-install -S git-absorb |
| GNU Guix | guix install git-absorb |
| Windows Package Manager | winget install tummychow.git-absorb |
Compiling from Source
You will need the following:
Then cargo install git-absorb. Make sure that $CARGO_HOME/bin is on your $PATH so that git can find the command. ($CARGO_HOME defaults to ~/.cargo.)
Note that git absorb does not use the system libgit2. This means you do not need to have libgit2 installed to build or run it. However, this does mean you have to be able to build libgit2. (Due to recent changes in the git2 crate, CMake is no longer needed to build it.)
Note: cargo install does not currently know how to install manpages (cargo#2729), so if you use cargo for installation then git absorb --help will not work. There are two manual workarounds, assuming your system has a ~/.local/share/man/man1 directory that man --path knows about:
- build the man page from source and copy
This requires that the a2x tool be installed on your system.
cd ./Documentation make mv git-absorb.1 ~/.local/share/man/man1 - download a recently-built man page
- find a recent build as in Installing above
- download the
git-absorb.1file and unzip - move it to
~/.local/share/man/man1
Usage
git addany changes that you want to absorb. By design,git absorbwill only consider content in the git index (staging area).git absorb. This will create a sequence of commits onHEAD. Each commit will have afixup!message indicating the message (if unique) or SHA of the commit it should be squashed into.- If you are satisfied with the output,
git rebase -i --autosquashto squash thefixup!commits into their predecessors. You can set theGIT_SEQUENCE_EDITORenvironment variable if you don't need to edit the rebase TODO file. - If you are not satisfied (or if something bad happened),
git reset --soft PRE_ABSORB_HEADwill reset to the pre-absorption commit and recover your old state. (You can also find the commit in question withgit reflog.) And if you thinkgit absorbis at fault, please file an issue.
How it works (roughly)
git absorb works by checking if two patches P1 and P2 commute, that is, if applying P1 before P2 gives the same result as applying P2 before P1.
git absorb considers a range of commits ending at HEAD. The first commit can be specified explicitly with --base <ref>. By default the last 10 commits will be considered (see STACK SIZE in git-absorb.adoc for how to change this).
For each hunk in the index, git absorb will check if that hunk commutes with the last commit, then the one before that, etc. When it finds a commit that does not commute with the hunk, it infers that this is the right parent commit for this change, and the hunk is turned into a fixup commit. If the hunk commutes with all commits in the range, it means we have not found a suitable parent commit for this change; a warning is displayed, and this hunk remains uncommitted in the index.
Documentation
For additional information about git-absorb, including all arguments and configuration options, see Documentation/git-absorb.adoc, or the git-absorb manual page.
TODO
- implement remote default branch check
- stop using
failure::err_msgand ensure all error output is actionable by the user - slightly more log output in the success case
- more tests (esp main module and integration tests)
- document stack and commute details
- more commutation cases (esp copy/rename detection)
- don't load all hunks in memory simultaneously because they could be huge
- implement some kind of index locking to protect against concurrent modifications