Kyl*_*ton 172
git
差异比标准的unix更具功能性diff
.我经常想这样做,因为这个问题在谷歌上排名很高,我希望这个答案出现.
这个问题:如何git diff --color-words
在Git存储库外部使用?
演示如何使用git通过使用以下方法来区分至少其中一个文件不在存储库中的文件--no-index
:
git diff --no-index file1.txt file2.txt
Run Code Online (Sandbox Code Playgroud)
无论哪一个被git跟踪哪个都没关系 - 一个或两个都可以不跟踪,例如:
$ date > x
$ sleep 2
$ date > y
$ git diff --color-words --no-index x y
diff --git a/x b/y
index 6b10c7c..70f036c 100644
--- a/x
+++ a/y
@@ -1 + 1 @@
Wed Jun 10 10:57:45|10:57:47 EDT 2013
Run Code Online (Sandbox Code Playgroud)
此处无法显示颜色,因此我在示例中使用管道分隔了更改.