【问题标题】:Checking out curl with git results in modified files which I cannot revert用 git 检查 curl 会导致修改后的文件无法恢复
【发布时间】:2016-07-27 04:49:40
【问题描述】:

当我像这样结帐 curl 时:

git clone https://github.com/bagder/curl.git

我得到(没有做任何事情)2个修改过的文件:

> git status
Your branch is up-to-date with 'origin/master'.
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

    modified:   winbuild/Makefile.msvc.names
    modified:   winbuild/MakefileBuild.vc

no changes added to commit (use "git add" and/or "git commit -a")

即使我尝试像这样签出这些文件:

git checkout winbuild/Makefile.msvc.names

它们仍然被修改。对git diff -R 的调用表明它可能与行尾有关,因为差异显示^M 附加到每一行。

由于在cmets中提示,问题与.gitattributes文件有关,这里是:

*.dsw -crlf
buildconf eol=lf
configure.ac eol=lf
*.m4 eol=lf
*.in eol=lf

删除我的 gitconfig 并没有改变这种情况,所以我想这与此无关。

顺便说一句,我在 ubuntu linux 上。

【问题讨论】:

  • 您使用的是 Linux 吗?应该是行尾问题。检查git diff -R 并查看这些文件是否被^M at the end of each line 替换。我希望这个 repo 的 .gitattributes 需要修复。
  • @hinerm 你似乎是对的。我在问题中添加了相关信息,但我仍然不知道如何解决这个问题

标签: git


【解决方案1】:

winbuild 中有第二个.gitattributes 文件,内容如下:

MakefileBuild.vc eol=crlf
Makefile.msvc.names eol=crlf
Makefile.vc eol=crlf

这些行导致使用 windows 样式的行尾。

解决此问题的一种方法是删除 .gitattributes 并将其签入 git。当然,这样就去掉了文件的初衷。

【讨论】:

    猜你喜欢
    • 2019-02-02
    • 2011-01-28
    • 2023-03-31
    • 2013-03-20
    • 2020-07-09
    • 2010-10-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多