Git Interactive Staging

Discussions center on using `git add -p` and similar commands like `git commit -p` to interactively stage specific hunks or changes for precise commits, reviewing work, and improving workflows.

➡️ Stable 1.0x DevOps & Infrastructure
3,644
Comments
20
Years Active
5
Top Authors
#4424
Topic ID

Activity Over Time

2007
1
2008
20
2009
26
2010
60
2011
113
2012
133
2013
154
2014
133
2015
135
2016
301
2017
172
2018
150
2019
251
2020
201
2021
327
2022
342
2023
227
2024
353
2025
537
2026
8

Keywords

GH porkrind.org gutter.el PSA JJ HEAD TortoiseGit WIP UI GUI git commit staging add git commit patch use git commits stash changes

Sample Comments

smichel17 Jul 12, 2020 View on HN

I like staging my changes with `git add -p` before I commit as a way of reviewing what I did. I often catch mistakes or unnecessary changes this way. I suppose you could build the same workflow with stashes, but it seems quite awkward that way.

gcv Jun 1, 2009 View on HN

Have you tried using 'git add --patch'? It will let you commit isolated changes.

adsche Feb 25, 2015 View on HN

Do you know about `git add -p`? That allows you to stage hunks or lines interactively in the terminal. Press `s` to split a hunk, `y`/`n` to stage or not stage.

ckuehl Sep 14, 2015 View on HN

You can simply use `git add -p` to stage hunks individually (or `git reset -p` to unstage some hunks).

kadoban Sep 26, 2024 View on HN

That sounds like what `git add -p` is for, stage part of the current changes.

fragmede Jan 15, 2017 View on HN

That's interesting, why not just do `git commit` at the command line?

TomK32 Dec 18, 2017 View on HN

I always do `git add --patch`, it's very precise and I can edit lines before staging them. I really don't see why someone would work without it (or a GUI).

tome Jan 18, 2019 View on HN

Do you know about `git commit -p`? You might like it even more than `git add -p`.

jimktrains2 May 1, 2018 View on HN

git add -pIt will let you approve each hunk in a file to commit or not.git commit -e -vWill force you to edit the commit message and in the editor show you the diff of the commit against HEAD.

lmm Dec 21, 2016 View on HN

Unfortunately git's staging area concept encourages you to do exactly the opposite of this.