如何使用git CLI交互提交(类似于hg CLI中的示例)? [英] How to interactively commit with git CLI, similar to the one here in hg CLI?
问题描述
我正在寻找一种非常接近于水银使用的解决方案,如下所示.我试过git add -p
,git add -e
,git add --interactive
,tig
和其他几个.
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.
但是,当我不得不对不同文件的多个块进行此操作时,这些方法却非常麻烦且烦人.
However these methods prove to be cumbersome and annoying when I have to do this across multiple hunks over different files.
请注意,GUI不是一个选择.
Note that GUI is not an option.
Edit-1:我尝试过vim逃犯,也无法在逃犯中选择这样的帅哥.
Edit-1: I've tried vim fugitive and can't select hunks like this in fugitive as well.
Edit-2:已删除与hg的比较.
Edit-2: Removed comparison with hg.
推荐答案
安德鲁·沙杜拉(Andrew Shadura)的 crecord扩展名正是我想要的.
Andrew Shadura's crecord extension is exactly what I was looking for.
设置如下:
git clone https://github.com/andrewshadura/git-crecord
cd git-crecord
./setup.py install
ln -s $PWD/git-crecord ~/.local/bin/git-crecord
cd到您的git repo并按以下方式调用它:
cd to your git repo and invoke it as follows:
git crecord
这将打开ncurses界面,该界面可以如下所示使用.在ncurses窗口中按以下键将执行某些操作:
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
这篇关于如何使用git CLI交互提交(类似于hg CLI中的示例)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!