这些git diff命令有什么区别?

时间:2014-12-08 20:49:41

标签: git git-diff

我在一个分支br上,按origin/br推送,我已经提交了几个提交。在HEAD == br == origin/br的情况下,我正在运行这两个命令:

(1) git diff <some-commit>

(2) git diff <some-commit> HEAD origin/br

其中HEAD<some-commit>

的直接后代

这两个给出了不同的结果,虽然我明白(1)是什么{I}我不知道(2)正在打印什么。 (2)做了什么?我相信它与手册页中的这个条目有关,但我不知道这意味着什么:

   <path>...
       The <paths> parameters, when given, are used to limit the diff to the named 
       paths (you can give directory names and get diff for all files under
       them).

1 个答案:

答案 0 :(得分:1)

我打赌输出显示diff -cc $pathnameindex $sha1,$sha2..$sha3,其中有时两个sha的1,2,3是相同的,并且从一些快速挖掘中我认为git可能会将其中一个提交(中间,它看起来像)视为显式合并基础,其他两个作为显式合并提示 - 但根据builtin/diff.c来自您的论点&#39;再传递不正确。

/*
 * We could get N tree-ish in the rev.pending_objects list.
 * Also there could be M blobs there, and P pathspecs.
 *
 * N=0, M=0:
 *  cache vs files (diff-files)
 * N=0, M=2:
 *      compare two random blobs.  P must be zero.
 * N=0, M=1, P=1:
 *  compare a blob with a working tree file.
 *
 * N=1, M=0:
 *      tree vs cache (diff-index --cached)
 *
 * N=2, M=0:
 *      tree vs tree (diff-tree)
 *
 * N=0, M=0, P=2:
 *      compare two filesystem entities (aka --no-index).
 *
 * Other cases are errors.
 */