“git diff” does nothing

后端 未结 5 1690
我寻月下人不归
我寻月下人不归 2021-01-30 12:32

I presume this is a configuration error somewhere, but I can\'t figure out where. Regular git commands appear to work fine, but \"git diff\" does nothing. To be safe, I remove

5条回答
  •  囚心锁ツ
    2021-01-30 13:05

    The default output for git diff is the list of changes which have not been committed / added to the index. If there are no changes, then there is no output.

    git diff [--options] [--] […]

    This form is to view the changes you made relative to the index (staging area for the next commit). In other words, the differences are what you could tell git to further add to the index but you still haven't.

    See the documentation for more details. In particular, scroll down to the examples, and read this section:

    $ git diff            # (1)
    $ git diff --cached   # (2)
    $ git diff HEAD       # (3)
    
    1. Diff the working copy with the index
    2. Diff the index with HEAD
    3. Diff the working copy with HEAD

    Outside your workspace, as you guessed, git won't know what to diff, so you have to explicitly specify two paths to compare, hence the usage message.

提交回复
热议问题