Git absorb

About 8 years ago I wrote a post about autosquashing commits. I have been comfortably doing this ever since, as it is pretty trivial to do as long as you maintain proper committing discipline. Which I do, pretty much all the time.

So I had never given this topic any more thought. Imagine my surprise when I found out today via a post on Hacker News that not only can one push this idea further, but a tool exists that does it for you.

It's called git-absorb (https://github.com/tummychow/git-absorb) and it's inspired by a preceding tool written for Mercurial at Facebook. It works by looking through the preceding commits and checking which ones modified the same lines that are currently modified by hunks in the index, then using fixup to add that hunk to that commit. You end up with a list of fixup commits which you can check through and rebase all at once.

This is one of those things that leave me simultaneously pleased that it exists, and maybe a tiny bit annoyed at myself for not going a little further on the topic, and thinking of it myself.

Either way, I'm now going to start using it.