Daily Software Tips & Tricks

Bite-sized knowledge to improve your coding skills daily.

Master Selective Commits with git add -p

May 28, 2026

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.