# Mastering Git Add -p for Precise and Organized Commits

Original title: Staging patches with Git add -p

> Hacker News story 49048570 · language: en · submitted 2026-07-25
> Web version: https://zeli.app/story/49048570
> About this feed: https://zeli.app/llms.txt · Agent guide: https://zeli.app/skill.md

▲ 34 · by [ankitg12](<https://news.ycombinator.com/user?id=ankitg12>) · 💬 52
[original](<https://www.simonholywell.com/post/git-add-p/>) · [HN discussion](<https://news.ycombinator.com/item?id=49048570>)

## Summary

I rely on git add -p daily to review changes interactively, catching bugs and typos before committing. This tool lets me stage specific hunks within a file, allowing me to group related changes into cleaner, more organized commits. By splitting diffs and selectively approving parts of a file, I maintain greater control over my version history and ensure only the intended code reaches the repository.

## Key quote

> If you're not already using git add -p to stage your commits then you're missing out.

## HN discussion (52 comments)

### [chriswarbo](<https://news.ycombinator.com/item?id=49103906>)

> Magit allows selective staging/unstaging, either of hunks, or by selecting lines (AKA Emacs's "region"). I avoid staging from the git commandline, unless I'm just doing whole files.
>
> PS: Majutsu provides this too (a magit-like tool for jj)

### [BeetleB](<https://news.ycombinator.com/item?id=49104004>)

> \> If you’re not already using git add -p to stage your commits then you’re missing out.
>
> After switching to jujutsu, I assure you I don't miss this feature.
>
> jj takes the opposite approach. It keeps staging things, and you use split whenever you want to separate things out.
>
> (And yes, it stores the staged changes as revisions, so you can always back out to a previous staged state).

### [natbennett](<https://news.ycombinator.com/item?id=49103677>)

> In the case of a newly committed file you can add just the file with
>
> git add . -N
>
> And then review the text itself as part of the git add -p workflow

### [wps](<https://news.ycombinator.com/item?id=49104661>)

> While I see the utility of partial file commits, I think that it promotes committing untested code. Fossil scm doesn’t have an equivalent feature because of this very issue.

### [ninkendo](<https://news.ycombinator.com/item?id=49104065>)

> My biggest problem with `add -p` is correcting any patches I added or rejected by accident. Often times I skip through dozens of things I don’t want to add, then realized that last hunk was something I did need. But I can’t re-visit it, I have to start over and try extra hard to not skip past it again.
>
> I wish the j and k shortcuts could revisit hunks I’ve already added/rejected, not just ones I haven’t reviewed yet. On a large set of unstaged changes that you mostly don’t want, it really sucks to “lose your place” in the list of hunks.

---

## Cite

- Page: https://zeli.app/story/49048570
- Date: 2026-07-25
- Source: simonholywell.com (https://www.simonholywell.com/post/git-add-p/)
- Hacker News: https://news.ycombinator.com/item?id=49048570

## Other languages

- zh: https://zeli.app/zh/story/49048570 · markdown: https://zeli.app/zh/story/49048570.md
