Daily Software Tips & Tricks
Bite-sized knowledge to improve your coding skills daily.
Clean Up Your Commits with Git Patch Mode
May 21, 2026
Ever committed a giant file only to realize you included temporary debug statements or half-finished experiments? Instead of staging the entire file, try using `git add -p` (short for patch). This command launches an interactive session that lets you review every single change, or "hunk," in your codebase before staging it.
You can decide to stage a change (y), skip it (n), or even split the hunk into smaller pieces (s) if you've got unrelated edits close together. It's an absolute game-changer for keeping your git history clean, focused, and easy for your team to review.