克隆后立即更改git仓库?

4

刚刚克隆了这个,目录里立即有变化?

我从未遇到过这样的情况,我想知道为什么会发生这种情况?这怎么可能?

更新:

我使用git clone git://github.com/horndude77/open-scores.git克隆了该存储库,运行git status后立即显示:

git status
# Not currently on any branch.
# 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:   SaintSaensRomanceOp36/defs.ily
#       modified:   SaintSaensRomanceOp36/horn.ily
#
no changes added to commit (use "git add" and/or "git commit -a")

git diff 显示:

warning: CRLF will be replaced by LF in SaintSaensRomanceOp36/defs.ily.
The file will have its original line endings in your working directory.
warning: CRLF will be replaced by LF in SaintSaensRomanceOp36/horn.ily.
The file will have its original line endings in your working directory.
diff --git a/SaintSaensRomanceOp36/defs.ily b/SaintSaensRomanceOp36/defs.ily
index 07e09ac..c7961be 100644
--- a/SaintSaensRomanceOp36/defs.ily
+++ b/SaintSaensRomanceOp36/defs.ily
@@ -1,47 +1,47 @@
-\version "2.13.13"
.
.
.

注意:由于内容过长,仅包含差异的顶部。

当我克隆仓库时,它是否删除了CRLF字符?如果是这样,那么这些字符是如何被包含在提交中的呢?


2
你是如何克隆它的,你又是如何知道有什么变化的? - Blender
你正在使用哪个操作系统? 在Windows上使用时,CRLF更改往往会发生。 - Whitecat
我正在使用Mac OS 10.7.4进行工作。 - rudolph9
你解决了这个问题吗?出了什么问题? - Whitecat
@whitecat 看起来只是 CRLF 被替换了。 - rudolph9
2个回答

5

当使用Windows机器进行提交时,包含的CRLF字符在克隆存储库时会被自动移除。Git会检测到这种变化,因此除了git clone操作之外,用户无需做任何其他操作就能在克隆后修改存储库。

我通过从我的.gitattributes文件中删除* text=auto来解决这个问题。


谢谢,这个答案对我很有帮助,但是我如何避免这样的事情发生呢? - Hanfeng
或者标记实际上是二进制的文件,例如: *.ttf 二进制 - Ding-Yi Chen

2
这是一个有关Windows和Linux的差异问题。有一个栈溢出的问题解决了这个问题
你可以通过简单地执行以下操作来修复它:
$ git config core.autocrlf true

1
有关原始问题的问题应作为评论提交。 - rudolph9
谢谢您的建设性评论,我将来会注意这一点。我已经编辑了答案,删除了问题。 - Whitecat
1
这仍然没有回答问题,问题是在问什么是原因,而不是如何检查更改。 - rudolph9
你是对的。我进一步澄清了解决方案。我还添加了一个链接到一个stackoverflow帖子,回答了你的问题。 - Whitecat
如果问题是重复的,你应该将其标记为重复,而不是将其提交为答案。 - rudolph9

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接