Git什么时候将文件显示为已修改,实际上它不是什么时候?

时间:2012-05-03 04:06:25

标签: git-diff

git diff的输出表示我的一个文件的完整内容已被删除,然后再添加回来。这是为什么?

diff --git a/templates/appengine/go/app.yaml b/templates/appengine/go/app.yaml
index 303af12..223b642 100644
--- a/templates/appengine/go/app.yaml
+++ b/templates/appengine/go/app.yaml
@@ -1,13 +1,13 @@
-# Right now, we direct all URL requests to the Go app we are about to
-# construct, but in the future we may add support for jQuery and Bootstrap
-# to automatically put a nice UI on the / url.
-
-application: {{ app_id.downcase }}
-version: 1
-runtime: go
-api_version: 3
-
-handlers:
-- url: /.*
-  script: _go_app
-
+# Right now, we direct all URL requests to the Go app we are about to
+# construct, but in the future we may add support for jQuery and Bootstrap
+# to automatically put a nice UI on the / url.
+
+application: {{ app_id.downcase }}
+version: 1
+runtime: go
+api_version: 3
+
+handlers:
+- url: /.*
+  script: _go_app
+

2 个答案:

答案 0 :(得分:2)

如果您已经转换了行结尾,那么这种git diff输出是预期的(例如,通过使用在Windows中运行的具有Unix样式行结尾的不良行为编辑器开始,结果为LF - > CR LF转换)。这是更改文件的每一行而不是更改空白区域的典型方法,您通常无法从原始diff输出解码到终端。

-w的选项git diff会使git diff忽略空格更改。在你的情况下git diff -w会是什么样子?如果它没有显示任何变化,那么空格就是输出的原因。

在这种情况下,您可以git diff | tr '\r' '~'查看CR字符中'~'字符更改为git diff字符(假设提供了Unix工具)。

答案 1 :(得分:0)

它显示了它,因为它在一次提交中被删除然后重新加入。所以当前状态和最后一次提交之间的差异已经改变。

相关问题