如何停止在mintty中使用git add -patch时未显示提示符

9
在cygwin中使用git add --patch somefile.txt时,我得到了一个奇怪的响应。
在首次输入命令后,它会等待我按下enter键而不显示任何内容。一旦我按下enter键,就会得到以下输出结果。
--- a/somefile.txt
+++ b/somefile.txt  
@@ -m,n +m,n @@
-Aple
+Apple
 Bear
 Cat
 Dog

Stage this hunk [y,n,q,a,d,/,j,J,g,e,?]? y - stage this hunk
n - do not stage this hunk
q - quit; do not stage this hunk nor any of the remaining ones
a - stage this hunk and all later hunks in the file
d - do not stage this hunk nor any of the later hunks in the file
g - select a hunk to go to
/ - search for a hunk matching the given regex
j - leave this hunk undecided, see next undecided hunk
J - leave this hunk un

并在un之后留下克拉

选择完成后,这种情况下是n,我得到了其余部分

J - leave this hunk unn
decided, see next hunk
k - leave this hunk undecided, see previous undecided hunk
K - leave this hunk undecided, see previous hunk
s - split the current hunk into smaller hunks
e - manually edit the current hunk
? - print help
@@ -1,4 +1,4 @@
-Lne 1
+Line 1
 Line 2
 Line 3
 Line 4
Stage this hunk [y,n,q,a,d,/,j,J,g,e,?]? @@ -289,6 +289,8 @@
 Line 289
 Line 290
 Line 291
+Line 292
+Line 293
 Line 294
 Line 295
 Line 296

文件的其余部分也遵循同样的模式,这让我无法确定哪个块正在被提示。
2个回答

6

在使用Cygwin时,我通常会看到两个与git相关的设置。

第一个设置(如果您的git config -l中没有包含它)是关于分页器的(如此gitconfig文件所示)。

git config core.pager C:/cygwin/root/bin/less.exe

[core]
        # we want to use cygwin's less, because msys's doesn't play well
        # with i/o via cygwin bash. This would be the default, but for the fact
        # that msysgit prepends `dirname argv[0]` to $PATH.
        pager = C:/cygwin/root/bin/less.exe

另外一些内容涉及TTY,例如这篇博客文章

export TERM=cygwin
export LESS=FRSX

其中一个设置可以使您的 git add -p 运行更加顺畅。


唉,这些都不起作用,我猜测与输入和输出流的使用方式有关。 - James Robinson
我已经授予这个答案赏金,因为它是唯一的答案,而且赏金即将到期。然而,这些设置在我的机器上没有任何区别。 - James Robinson

1
鉴于此问题所收到的投票数量,看来我不是唯一遇到这个问题的人。
似乎Cygwin的默认安装不包含git。但是,如果您已经单独安装了git,则它将被添加到Windows路径中,并且在其他方面看起来可以正常工作。
例如:
> which git
c:\Program Files (x86)\Git\bin\git

一旦我通过Cygwin安装了git并且使用了那个版本,问题就得到解决了。
即。
> which git
/usr/bin/git

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接