git diff和gif diff-index有什么区别 [英] What's the difference between git diff and gif diff-index
问题描述
当我想获取git diff文件时,发现有人在使用
When I want to get git diff files, I found someone use
git diff-index --cached --diff-filter=AM --name-only HEAD
如果我使用
git diff --cached --diff-filter=AM --name-only HEAD
可以获得相同的结果.
那么git diff
和git diff-index
有什么区别?
什么时候必须使用git diff-index
而不是git diff
?
can get the same result.
So what's the difference between git diff
and git diff-index
?
When you must use git diff-index
but not git diff
?
推荐答案
git diff-index
是与索引或工作树的差异:
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
功能更全面,可以比较两个文件或两次提交,或(像diff-index一样)一棵树和索引.
git diff
is more versatile and can compare two files, or two commits, or (like diff-index) a tree and the index.
在您的情况下,diff HEAD
确实会将HEAD与索引进行比较,而diff-index
也会这样做.
In your case, a diff HEAD
would indeed diff HEAD against the index, which diff-index
does too.
这篇关于git diff和gif diff-index有什么区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!