Daily Software Tips & Tricks
Bite-sized knowledge to improve your coding skills daily.
Master the Art of Selective Commits with 'git add -p'
May 29, 2026
Ever finished a long coding session only to realize you've written three different features, fixed a bug, and left a bunch of debug console.log statements in a single file? Instead of committing everything in one massive, chaotic dump, use 'git add -p' (or '--patch'). This command lets you review your changes hunk by hunk, deciding exactly what goes into the staging area and what stays out.
It's like having a final code review with yourself before making things official. You can stage the actual feature, discard the debug statements, and keep your git history incredibly clean and readable for your team.