DEV Community

Toolloom
Toolloom

Posted on • Originally published at toolloom.com on

Master Selective Commits with git add -p

Ever finished a long coding session only to realize your working directory is a mess of different logical changes? Instead of staging everything at once with git add ., try using git add -p (or --patch). This command runs an interactive session that steps through your changes hunk by hunk, letting you decide exactly what goes into the next commit.

You can stage a specific change, skip it, or even split a large hunk into smaller pieces. It's an absolute game-changer for keeping your commit history clean, readable, and easy to review during pull requests.

Top comments (0)