My common workflow is to do a bunch of code editing, and then use git add --patch
to organize my changes into logically consistent commits.
A scenario that comes up over and over again is this:
- I skip a bunch of changes that don't relate to the commit I want to make
- I add some changes that make sense
- I find a typo or some commented-out code that I forgot to delete
- I hit
q
to exit the interactive add - I go back to my editor and make the small change
- I start
git add --patch
again - I very carefully walk through the entirety of the change set again, making sure to type
n
over again for all the hunks I don't want to include - I reach my newly updated hunk and type
y
to add it. - GOTO step 1
This cycle plays out over and over again until finally my commit is ready to go.
What I'd like is for git to remember which hunks I've explicitly declined to add, so that the next time I run git add --patch
, I don't have to decline them again.
I don't think git supports this, but is there any tool or workflow I could adapt that would make this easier?