DEV Community

Toolloom
Toolloom

Posted on • Originally published at toolloom.com on

Master the Art of Selective Commits with 'git add -p'

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.

Top comments (0)