+1
日增长
5,763
stars
114
forks
18
watchers
103
prs
115
issues
22
releases
README
git absorb
This is a port of Facebook's hg absorb, which I first read about on mozilla.dev.version-control:
Facebook demoed hg absorb which 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 run hg absorb and the uncommitted modifications are automagically folded ("absorbed") into the appropriate draft ancestor changesets. This is essentially doing hg 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, run hg absorb and 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 |
Top issues
#19Generate one fixup per commit, not per-hunk?13 comments · 2019-07-14#37Getting "old path already occupied"12 comments · 2020-11-23#72Consider GIT_AUTHOR_EMAIL/GIT_COMMITTER_EMAIL as current author/committer11 comments · 2022-11-29#48Respect pre-commit hooks7 comments · 2021-09-16#107add -u / --auto-stage command-line parameter to toggle autostage6 comments · 2024-03-28#46"No additions staged" when a new file is added6 comments · 2021-08-22#216git 2.55 history fixup4 comments · 2026-06-30#212`git absorb` does not complete even after installing completion4 comments · 2026-03-12
Latest release
0.9.0 0.9.0 2026-02-14What'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