[英]git diff between two different files
In HEAD
(the latest commit), I have a file named foo
.在
HEAD
(最新提交)中,我有一个名为foo
的文件。 In my current working tree, I renamed it to bar
, and also edited it.在我当前的工作树中,我将其重命名为
bar
,并对其进行了编辑。
I want to git diff
foo
in HEAD
, and bar
in my current working tree.我想在
HEAD
git diff
foo
,并在我当前的工作树中使用bar
。
I believe using --no-index
is what you're looking for:我相信使用
--no-index
是您正在寻找的:
git diff [<options>] --no-index [--] <path> <path>
as mentioned in the git manual:如 git 手册中所述:
This form is to compare the given two paths on the filesystem.
这种形式是比较文件系统上给定的两个路径。 You can omit the
--no-index
option when running the command in a working tree controlled by Git and at least one of the paths points outside the working tree, or when running the command outside a working tree controlled by Git.在 Git 控制的工作树中运行命令并且至少有一个路径指向工作树之外,或者在 Git 控制的工作树之外运行命令时,您可以省略
--no-index
选项。
如果您使用的是 tortoise git,您可以右键单击一个文件并通过以下方式 git diff:右键单击第一个文件并通过 tortoisegit 子菜单选择“稍后比较”然后在第二个文件上您也可以右键单击此文件,转到 tortoisegit 子菜单,然后选择“Diff with yourfilenamehere.txt”
使用PhpStorm,我只复制了先前的提交代码,并使用内置的“与剪贴板比较”工具将其与当前版本进行比较。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.