Tooling: git absorb

Tags:

My development workflow looks something like this

  • Implement feature 1
  • Implement another feature 2
  • Bug fixes for something in feature 2
  • Bug fixes for feature 1
  • More bug fixes for something in feature 2

This results in a git history like the above, which I then interactively rebase into

add Implement feature 1 squash Bug fixes for feature 1 add Implement another feature 2 squash Bug fixes for something in feature 2 squash More bug fixes for something in feature 2

The git absorb command automates part of the rebase by looking at the currently staged hunks and finding the commit that most recently changed lines in that hunk, and squashing that hunk in that commit:

git add app.pl -p # add the parts for feature 1 and feature 2 that don't overlap git absorb