DEV Community

Toolloom
Toolloom

Posted on • Originally published at toolloom.com on

Master Selective Commits with Git Add Patch

Ever finished a long coding session and realized you've written code for three different features, but you want to keep your commit history clean? Instead of committing everything at once, use git add -p (or --patch). This command runs an interactive session that walks you through every single change in your workspace, letting you decide whether to stage it, skip it, or even split a change into smaller pieces.

It's a lifesaver for keeping your pull requests focused and easy to review. Your future self—and your teammates—will thank you for commits that actually match their commit messages.

Top comments (0)