Search code examples
gitgit-diff

No diff output in interactive staging


I get normal git diff output on the command line without problem:

--- 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)

However in interactive staging mode I get nothing:

> 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>

I assume git is trying to use some command for output that it's not finding, something other than less which is working fine for normal diff. What is it or where do I specify it?


Solution

  • Have a look at git-add(1):

    diff

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

    Since you did not add anything yet, the diff is empty. In contrast git-diff compares HEAD with the working directory. The call from the interactive add is akin to git diff --cached.