What's the difference between git diff and gif diff-index

前端 未结 2 598
别那么骄傲
别那么骄傲 2021-02-18 21:19

When I want to get git diff files, I found someone use

git diff-index --cached  --diff-filter=AM --name-only  HEAD

and if I use



        
2条回答
  •  别跟我提以往
    2021-02-18 21:50

    git diff-index is a diff against the index or working tree:

    Compares the content and mode of the blobs found in a tree object with the corresponding tracked files in the working tree, or with the corresponding paths in the index

    git diff is more versatile and can compare two files, or two commits, or (like diff-index) a tree and the index.

    In your case, a diff HEAD would indeed diff HEAD against the index, which diff-index does too.

提交回复
热议问题