交互式暂存中没有差异输出

No diff output in interactive staging

我在命令行上正常 git diff 输出没有问题:

--- a/my_file.rb
+++ b/my_file.rb
@@ -108,6 +108,8 @@ my_block do
     #unchanged line
     #unchanged line
     #unchanged line
+    #new line
+    #new line
     #unchanged line
(END)

但是在交互式暂存模式下我什么也没得到:

> git add -i my_file.rb
staged     unstaged path
  1:    unchanged        +2/-0 my_file.rb

*** Commands ***
  1: status       2: update       3: revert       4: add untracked
  5: patch        6: diff         7: quit         8: help
What now> 6
*** Commands ***
  1: status       2: update       3: revert       4: add untracked
  5: patch        6: diff         7: quit         8: help
What now>

我假设 git 正在尝试使用一些它没有找到的输出命令,而不是 less 对于正常差异工作正常的命令。它是什么或我在哪里指定它?

看看git-add(1):

diff

This lets you review what will be committed (i.e. between HEAD and index).

由于您还没有添加任何东西,差异是空的。相反 git-diff 将 HEAD 与工作目录进行比较。来自交互式添加的调用类似于 git diff --cached.