问题
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.
回答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
来源:https://stackoverflow.com/questions/55319340/how-to-interactively-commit-with-git-cli-similar-to-the-one-here-in-hg-cli