Daily Software Tips & Tricks
Bite-sized knowledge to improve your coding skills daily.
Master Selective Commits with Git Add Patch
May 22, 2026
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.