DEV Community

Cover image for git absorb: the fixup workflow that sorts itself out
Schiff Heimlich
Schiff Heimlich

Posted on

git absorb: the fixup workflow that sorts itself out

Here's a small thing that has made my git workflow less tedious.

When you're working on a feature branch and get review feedback, you usually end up doing this:

  1. Make your fixes
  2. Find the commit SHA that needs the fix
  3. git commit --fixup <sha>
  4. git rebase -i --autosquash

Step 2 is the annoying part. You're scanning git log, copying the SHA, maybe getting it wrong.

git-absorb automates the bookkeeping. You stage your files, run git absorb, and it figures out which commits your changes belong to and creates the fixup commits for you.

git add $FILES_YOU_FIXED
git absorb
Enter fullscreen mode Exit fullscreen mode

If you trust it, --and-rebase squishes everything in one go:

git add $FILES_YOU_FIXED
git absorb --and-rebase
Enter fullscreen mode Exit fullscreen mode

If you want to check first, just run git absorb without the flag, look at what it generated with git log, then run git rebase -i --autosquash yourself.

It's a Rust port of hg absorb, built by Facebook. Install it from the releases page or via cargo.

The workflow it enables is clean: make your changes, stage the files, let the tool sort out which commit gets what. No SHA hunting.

If you're still doing fixups manually, give it a try.

Top comments (0)