1

I'm looking for a solution very close to the usage with mercurial, as seen below. I have tried git add -p, git add -e, git add --interactive, tig and few others.

I've also looked at this and this.

However these methods prove to be cumbersome and annoying when I have to do this across multiple hunks over different files.

Note that GUI is not an option.

Edit-1: I've tried vim fugitive and can't select hunks like this in fugitive as well.

Edit-2: Removed comparison with hg.

enter image description here

Arun
  • 1,399
  • 12
  • 21
  • 1
    I'm not sure why I'm getting down voted. It's a genuine question. How are git users doing this? – Arun Mar 24 '19 at 01:13
  • 1
    I don’t see a question. Apart from making a statement about mercurial having a better interactive hunk adding, what is your question? – evolutionxbox Mar 24 '19 at 01:51
  • My question is about how to get a ncurses interface in git to select the hunks from multiple different files at once. Whoever I talked to about git goes on to say use `git add -p`. The mercurial example was provided as a way to relate how it does to show people what I actually mean. – Arun Mar 24 '19 at 02:14
  • The previous suggestions is how to do it natively in git. Anything else close to what you want is likely to be provided by another tool, which is sadly off topic for SO, but I’d love to know what you find. – evolutionxbox Mar 24 '19 at 02:17
  • 2
    Downvote from me: It is impossible to deduce *from the text* what is really the intention of the question. Having to look at a video which is only slightly relevant AND to extract the relevant parts from there -- really ugly. – A.H. Mar 24 '19 at 08:38

1 Answers1

1

Andrew Shadura's crecord extension is exactly what I was looking for.

Set it up as follows:

git clone https://github.com/andrewshadura/git-crecord
cd git-crecord
./setup.py install
ln -s $PWD/git-crecord ~/.local/bin/git-crecord

cd to your git repo and invoke it as follows:

git crecord

This would bring up the ncurses interface which can be used as shown below. Pressing the following keys in the ncurses window will do certain actions:

f       hunk toggle fold (arrow keys can also be used)
space   toggle hunk selection
a       toggle commit or amend
c       confirm and open commit window

enter image description here

Arun
  • 1,399
  • 12
  • 21