Daily Software Tips & Tricks

Bite-sized knowledge to improve your coding skills daily.

Mastering the Surgical Commit with Git Patch

April 21, 2026

Ever find yourself halfway through a feature only to realize you’ve also fixed three unrelated bugs and tweaked some formatting? Instead of dumping everything into one messy commit, try using git add -p. This opens up an interactive mode where Git breaks your changes into hunks, allowing you to decide piece-by-piece what goes into the stage. It’s the best way to keep your pull requests clean and your history readable.

If a hunk is too large, you can even split it further by hitting 's'. This level of control ensures that every commit tells a single, clear story, which your future self and your teammates will definitely appreciate during code reviews.