Sourcetree makes it easy to stage and unstage hunks. And also easy to select particular lines from within a hunk and stage or unstage them. I am trying to figure out how to do the same from the command line.
I tried doing each operation in sourcetree with the command history panel showing. It doesn't show any commands when I perform these operations. For other operations it works fine.
On the command line, I use git add
in interactive mode, choose the patch option and then select a file with a multiline change in it. The prompt is: "Stage this hunk [y,n,q,a,d,/,e,?]?". If I choose the '?' option it outputs this help text:
y - stage this hunk
n - do not stage this hunk
q - quit; do not stage this hunk or any of the remaining ones
a - stage this hunk and all later hunks in the file
d - do not stage this hunk or any of the later hunks in the file
g - select a hunk to go to
/ - search for a hunk matching the given regex
j - leave this hunk undecided, see next undecided hunk
J - leave this hunk undecided, see next hunk
k - leave this hunk undecided, see previous undecided hunk
K - leave this hunk undecided, see previous hunk
s - split the current hunk into smaller hunks
e - manually edit the current hunk
? - print help
The 's' option looks like the right one for staging individual lines out of the hunk. However, when I enter it, git just outputs the help text again.
Can anyone tell me where in the docs I should be looking?