Daily Software Tips & Tricks
Bite-sized knowledge to improve your coding skills daily.
Craft cleaner commits with Git's interactive staging
May 20, 2026
Ever find yourself with a giant file of changes, but you only want to commit a portion of them to keep your pull request clean? Instead of committing the whole file, try using `git add -p` (or `--patch`). This command runs an interactive prompt that steps you through each change, or "hunk," in your codebase, letting you decide whether to stage it, skip it, or even split it into smaller pieces.
It’s an absolute game-changer for keeping your commit history logical and readable. Your future self—and your teammates during code reviews—will thank you for not bundling unrelated bug fixes and formatting tweaks into one massive commit.