DEV Community

Toolloom
Toolloom

Posted on • Originally published at toolloom.com on

Master Git Interactive Staging for Cleaner Commits

We’ve all been there: you’re working on a feature, get distracted, fix a couple of typos in another file, and add some temporary debug logs. Now you have a giant mess of changes to commit. Instead of committing everything at once or meticulously copy-pasting code, try using git add -p (or git add --patch).

This command lets you review your changes chunk by chunk. Git will show you a "hunk" of code and ask if you want to stage it, skip it, or even split it into smaller pieces. It’s a game-changer for keeping your pull requests clean, focused, and incredibly easy for your team to review.

Top comments (0)