3 ms·
Say you have 3 sequential lines, but you only want to stage the middle one. You can’t split it into smaller hunks by hitting ‘s’ during ‘git add -p’. I’m sure
by dasil003 9y ago
Say you have 3 sequential lines, but you only want to stage the middle one. You can’t split it into smaller hunks by hitting ‘s’ during ‘git add -p’. I’m sure there’s a way I’m just not familiar with but I just use Sourcetree for this on the rare occasion it occurs.
- klmr 9y agoYou can split hunks manually by editing (hit “e” instead of “s” during staging). I end up doing this fairly regularly.
- rickycook 9y agoi think that’s his point? there’s a huge amount of useful, but advanced functionality in the git CLI
- jgtrosh 9y agoAs mentioned before, manual edits can be made at that point. However I'll add that for this use case, a tool integrated in your editor will often be more adapted to manual staging. I have Tim Pope's vim-fugitive plugin in mind which is a quite wonderful way of using Git.
- u801e 9y agoYou can also manually edit the hunk to remove the 2 lines you don't want to stage and use the recountdiff utility to update the hunk header.