DEV Community

Toolloom
Toolloom

Posted on • Originally published at toolloom.com on

The Secret to Clean Commits: Patch Mode

Ever finish a coding session only to realize you made three unrelated changes in one file (a bug fix, a refactor, and a commented-out line)? Don't commit everything together! Use git add -p (or git add --patch). This command lets you review changes hunk-by-hunk and decide exactly which specific blocks of code belong in your next commit. Atomic commits—commits that do one thing and one thing only—make reviewing and reverting changes infinitely easier for your teammates (and your future self when debugging.)

Top comments (0)