我在主分支中有一个包含文件foo的存储库。我切换到bar分支,并对foo进行了一些更改。现在如何在此副本(尚未提交)和主分支的副本之间运行git diff?
发布于 2012-02-02 21:46:17
下面的方法对我很有效:
git diff master:foo foo
在过去,它可能是:
git diff foo master:foo
发布于 2013-04-02 21:52:12
您正在尝试将您的工作树与特定的分支名称进行比较,因此您需要这样:
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 (又名--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.发布于 2012-09-24 16:16:15
git difftool tag/branch filenamehttps://stackoverflow.com/questions/9113280
复制相似问题