Daily Software Tips & Tricks
Bite-sized knowledge to improve your coding skills daily.
Use Git Add Patch for Cleaner Commits
May 9, 2026
Ever found yourself halfway through a feature only to realize you've fixed three unrelated bugs in the same file? Instead of committing everything at once, try using git add -p in your terminal. This command opens an interactive mode that breaks your changes into 'hunks,' allowing you to decide piece-by-piece what goes into the next commit and what stays in your working directory.
It is a total game-changer for keeping your pull requests focused and your git history readable. It also forces you to review your code one last time before it ever hits the staging area, which is a great way to catch stray console logs or temporary comments you forgot to delete.