【问题标题】:Git diff filenames breaking consistencyGit diff 文件名破坏一致性
【发布时间】:2013-03-18 15:07:19
【问题描述】:

此行取自包含 2852 个文件更改(切换多个库)的原始差异。

diff --git "a/system/cms/config/database.php\n" "b/system/cms/config/database.php\n"

在所有 2852 个文件更改中,这是唯一一个文件名用引号括起来并以“\n”结尾的差异。其他所有相关行都符合这种模式。

diff --git a/system/cms/config/constants.php b/system/cms/config/constants.php

知道为什么会这样吗?

【问题讨论】:

    标签: git diff filenames git-diff


    【解决方案1】:

    发生这种情况是因为您实际上有一个文件名,其末尾包含 \n

    $ git init
    Initialized empty Git repository in /home/foo/tmp/.git/
    $ echo foo > a$'\n'
    $ git add a*
    $ git commit -m one
    [master (root-commit) 2ce40fd] one
     1 file changed, 1 insertion(+)
     create mode 100644 "a\n"
    $ echo bar >> a*
    $ git diff|less
    diff --git "a/a\n" "b/a\n"
    index 257cc56..3bd1f0e 100644
    --- "a/a\n"
    +++ "b/a\n"
    @@ -1 +1,2 @@
     foo
    +bar
    

    【讨论】:

      猜你喜欢
      • 2011-12-07
      • 1970-01-01
      • 2011-12-01
      • 2018-02-14
      • 2012-02-07
      • 2014-09-24
      • 1970-01-01
      • 2017-03-14
      • 2019-10-02
      相关资源
      最近更新 更多