Daily Software Tips & Tricks
Bite-sized knowledge to improve your coding skills daily.
Master the Art of Partial Commits with git add -p
March 23, 2026
Ever found yourself halfway through a feature only to realize you’ve also fixed three unrelated bugs and updated a config file? Instead of dumping everything into one messy commit, try using git add -p (or --patch). This command breaks your changes down into "hunks" and asks you, one by one, if you want to stage them. It’s a lifesaver for keeping your pull requests clean and your commit history readable.
It also gives you a final chance to review your code before it's staged, acting as a mini-self-code-review. If a hunk is too big, you can even use the 's' command to split it into smaller pieces. Your future self and your reviewers will thank you for the atomic commits.