Skip to content
Browse files

Ref/Git: Add section on git add -p

  • Loading branch information...
baltpeter committed Jul 31, 2019
1 parent 8c5f095 commit 3ad149adf9322fa1800c46deacac746e8ff13898
Showing with 13 additions and 0 deletions.
  1. +13 −0 content/reference/
@@ -65,3 +65,16 @@ This version however unfortunately doesn't work on Ubuntu because they use the *
# but unfortunately, Ubuntu uses `/bin/dash` as `/bin/sh` and that doesn't support that expansion. :(
fixup = "!f() { TARGET=$(git rev-parse "$1"); git commit --fixup=$TARGET && EDITOR=true git rebase -i --autostash --autosquash $TARGET^; }; f"

## Staging only parts of a file

Sometimes, you don't want to `git add` a whole file but only a part of it. This can be done using `git add -p` which will then interactively ask you which parts to stage.

Possible commands for each hunk are ([1](

* `y`: Add this hunk
* `n`: Don't this hunk
* `d`: Skip the rest of the file
* `s`: Split into smaller hunks (only works if there are unchanged lines in-between)
* `e`: Edit hunk in editor
When editing, make sure that each line starts with one of these characters: ` ` (unchanged line), `-` (remove line), `+` (add line).

0 comments on commit 3ad149a

Please sign in to comment.
You can’t perform that action at this time.