How to interactively commit with git CLI, similar to the one here in hg CLI?
Asked Answered
H

1

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

Hippel answered 23/3, 2019 at 23:31 Comment(5)
I'm not sure why I'm getting down voted. It's a genuine question. How are git users doing this?Hippel
I don’t see a question. Apart from making a statement about mercurial having a better interactive hunk adding, what is your question?Jericajericho
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.Hippel
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.Jericajericho
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.Ulysses
H
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

Hippel answered 24/3, 2019 at 18:7 Comment(1)
Glad you found what you were looking for. In future please note that asking for a plug-in is off topic.Jericajericho

© 2022 - 2024 — McMap. All rights reserved.