DEV Community

Toolloom
Toolloom

Posted on • Originally published at toolloom.com on

Mastering Granular Commits with Git Add Patch

Ever find yourself finishing a long coding session only to realize you’ve changed three different things in one file? Instead of dumping everything into a single messy commit, try using git add -p. This command opens an interactive mode that lets you review each "hunk" of code changes one by one.

You can decide to stage a specific change, skip it, or even split it into smaller pieces if the hunk is too large. It’s a total game-changer for keeping your pull requests clean, focused, and much easier for your teammates to review.

Top comments (0)