Answers:
以下对我有用:
git diff master:foo foo
在过去,可能是:
git diff foo master:foo
--以便将参数与路径参数分开?git diff -- master:foo foo
git diff -- master:foo foo它不起作用-似乎将arg master:foo视为不存在的文件名(并且将其忽略),而不是分支文件。尝试切换最后2个args-如果可行,则diff比较应该反转,但输出不会改变。
git diff master:foo foo,反之亦然。我也不明白。使用git 1.7.9.5 / Ubuntu 12.04,我至少可以做得到git diff -R master:foo foo我真正想要的差异。当我尝试使用msysgit 1.9.4 / Windows 7 x64时,我得到了fatal: unable to read 0000000000000000000000000000000000000000。没有-R我,我得到与git 1.7.9.5相同的错误消息,但是有了1.9.4我得到了fatal: master:foo: no such path in the working tree。
您正在尝试将工作树与特定分支名称进行比较,因此您需要这样做:
git diff master -- foo
这是来自git-diff的这种形式(请参见git-diff手册页)
git diff [--options] <commit> [--] [<path>...]
This form is to view the changes you have in your working tree
relative to the named <commit>. You can use HEAD to compare it with
the latest commit, or a branch name to compare with the tip of a
different branch.
仅供参考,还有一个--cached(aka --staged)选项用于查看您已上演的内容的差异,而不是工作树中的所有内容:
git diff [--options] --cached [<commit>] [--] [<path>...]
This form is to view the changes you staged for the next commit
relative to the named <commit>.
...
--staged is a synonym of --cached.
也: git diff master..feature foo
由于git diff foo master:foo不适用于我的目录。
git diff branch1:foo master:foo
git difftool tag/branch filename
git diff mybranch master -- file
应该也可以
git diff deployment master -- file并且git diff master deployment -- file可以与任意两个分支正常工作。
git diff,我总是想起stackoverflow.com/questions/5256249/git-diff-doesnt-show-enough/...