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.
Activity Over Time
Top Contributors
Keywords
Sample Comments
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.
Have you tried using 'git add --patch'? It will let you commit isolated changes.
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.
You can simply use `git add -p` to stage hunks individually (or `git reset -p` to unstage some hunks).
That sounds like what `git add -p` is for, stage part of the current changes.
That's interesting, why not just do `git commit` at the command line?
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).
Do you know about `git commit -p`? You might like it even more than `git add -p`.
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.
Unfortunately git's staging area concept encourages you to do exactly the opposite of this.