News for hackers. Stuff that matters.
Re:Guitar – Git GUI Client by richardwhiuk on Wednesday April 22, 2020 @06:05AM (#22943977)
`git add -p` is pretty fast for staging parts of files
Re:Guitar – Git GUI Client by konart on Wednesday April 22, 2020 @07:14AM (#22944349)
Unless I'm missing something - it only shows you a hunk, without much (or any) context. It's relatively fast to stage hunk like this, but you are doing it like blindly.
Re:Guitar – Git GUI Client by skrtskrt on Wednesday April 22, 2020 @12:39PM (#22947442)
I use git add -p almost exclusively & I'm a big fan, to me the limitation is when the part I want to stage and the part I don't are so close together that they get presented to me as a single atomic chunk to add/not add.
Re:Guitar – Git GUI Client by dbalatero on Wednesday April 22, 2020 @02:41PM (#22948802)
Do you ever hit 'e' to edit? You can alter the patch manually in Vim/$EDITOR – this is what I do when I hit those edge cases.
Re:Guitar – Git GUI Client by richardwhiuk on Sunday May 03, 2020 @04:17PM (#23061542)
You can also press 's' to split in some cases.
Re:Guitar – Git GUI Client by skrtskrt on Wednesday April 22, 2020 @04:52PM (#22950068)
Ah no - but I will now!

Still, usually what I need there is the ability to leave a line or two there but don't stage it.

Re:Guitar – Git GUI Client by u801e on Wednesday April 22, 2020 @10:15AM (#22945772)
An alternative is using TUI application like vim in conjunction with tools like recountdiff and git apply to handle staging and unstaging parts of files.

You get more context because you can see other parts of the diff in the editor, unlike when using the -p switch with the git add or reset commands.

Re:Guitar – Git GUI Client by konart on Wednesday April 22, 2020 @01:04PM (#22947730)
I'm actually using NeoVIM + fugitive and git-gutter.

GitGutter make working with hunks easy

Re:Guitar – Git GUI Client by u801e on Wednesday April 22, 2020 @03:53PM (#22949505)
Looking at the README of vim-gitgutter[1] (assuming that's the plugin you're referring to), it says the following:

>> You cannot unstage a staged hunk.

I'm not sure if that's a feature they plan to support, but something like this could easily be done by highlighting the hunk displayed when running git diff --cached in vim's linewise visual mode and filtering it through git apply -R --cached -.

[1] https://github.com/airblade/vim-gitgutter