Comment by wredcoll

3 months ago

I can't help with your actual problem but I am incredibly curious about how/why you run into this so frequently you need a tool for it. I feel like in my 15 or whatever years of using git I have basically never wanted to remove a hunk from an old commit or anything similar.

I try to leave a good commit trail in my PRs. These are often _not_ the reality of how the code was written and originally committed, but a rough approximation of the intended steps with the benefit of hindsight.

A tool like https://github.com/tummychow/git-absorb has been on my to-try list for a while, but for now I do it by hand.

  • git absorb works surprisingly well. I was quite skeptical in the beginning, but it really turned into something I used daily (until I switched to jj, where I haven't found a replacement yet). If you use stepwise commits I can really recommend it.

    small edit: It seems that jj supports `jj absorb` now as well. Wonderful!

I am often responsible for landing branches created by colleagues who are less disciplined about their diff cleanliness than me. Very often, attempting to regroup a spurious change from an early commit to a separate "cleanup" commit results in a long conflict hell.