09/25/2026
Git's Interactive Patch
This is a PSA to those who push messy commits. Clean, complete, single feature
commits are nice. The git add -p command will help you get there.
Interactive add
I've been using git add -i for a while now. When I would go a little while
without committing, it helped me intermittently step through my changes and do a
quick review of my work. After a while, I naturally found myself using it to
separate out specific changes into their own commits so that each of my commits
was a very concise, self-contained change. This helped me on a day-to-day basis
to view my train-of-thought and assist me to plan (or remember) my next steps.
It also makes reverting incredibly easy. Especially if you include good,
descriptive commit messages.
Of course git has a shorthand for that.
One thing I never found myself doing was anything other than git add -i, 5,
then *. This translates to "run git's interactive add subcommand", "add to a
patch", "include all files in the prompt". As it turns out, this is a common
enough endeavor to have its own argument. git add -p mimics this chain of
commands identically. If you find yourself committing directly after each time,
you can substitute in git commit -p.
Next time you plan on hitting the terminal with a git commit -am "continue working", maybe take an extra five to make it clean.