5 ms·
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
by konart 7y ago
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.
- skrtskrt 7y agoI 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.
- dbalatero 7y agoDo 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.
- skrtskrt 7y agoAh 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.
- richardwhiuk 6y agoYou can also press 's' to split in some cases.
- u801e 7y agoAn 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.
- konart 7y agoI'm actually using NeoVIM + fugitive and git-gutter. GitGutter make working with hunks easy
- u801e 7y agoLooking 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 https://github.com/airblade/vim-gitgutter