DEV Community

Toolloom
Toolloom

Posted on • Originally published at toolloom.com on

Don't Commit Everything: Patch Staging

We've all been there: you made three unrelated changes in one file, and now you only want to commit the bug fix, not the experimental feature. Instead of staging the whole file with git add, try using git add -p (or --patch). Git will walk you through the file, showing you "hunks" (blocks of changes) and asking if you want to stage each one individually. This keeps your commits clean, atomic, and easy to review, making your Git history a pleasure to read.

Top comments (0)