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

早过忘川 提交于 2019-12-13 10:37:12

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!