Arun
Arun

Reputation: 1449

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

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

Upvotes: 2

Views: 323

Answers (1)

Arun
Arun

Reputation: 1449

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

Upvotes: 2

Related Questions