git status 报告新克隆的存储库中已修改的文件

发布于 2024-09-08 08:26:17 字数 1536 浏览 3 评论 0原文

已解决

远程存储库似乎包含两个名称相同的文件,除了第一个字母。这导致我的系统上的文件被覆盖,从而导致以下问题。

更新

它似乎与换行符无关,但我还找不到解释。事情是这样的。

git status 报告 FileStartingWithCapitalLetter.php 已被修改

另一方面,浏览我的不区分大小写的文件系统,显示 fileStartingWithCapitalLetter.php,它实际上以小写字母开头“f”。

git diff FileStartingWithCapitalLetter.php

显示了这一点(差异很难发现,它是重定向中的 R,这让我认为它与 CRLF 有关):

diff --git a/test/functional/frontend/RedirectActionsTest.php b/test/functional/frontend/RedirectActionsTest.php
index 66e1fef..c574583 100644
--- a/test/functional/frontend/RedirectActionsTest.php
+++ b/test/functional/frontend/RedirectActionsTest.php
@@ -5,10 +5,10 @@ include(dirname(__FILE__).'/../../bootstrap/functional.php');
 $browser = new sfTestFunctional(new sfBrowser());
 
 $browser->
-  get('/Redirect/index')->
+  get('/redirect/index')->
 
   with('request')->begin()->
-    isParameter('module', 'Redirect')->
+    isParameter('module', 'redirect')->
     isParameter('action', 'index')->
   end()->

另一方面,git diff fileStartingWithCapitalLetter.php(小写 f),显示没有任何变化。

有什么解决办法吗?

老问题

我克隆了一个 git 存储库,然后立即执行 git status。看到它报告修改的文件并不奇怪,就像我以前发生过的那样。 Windows 机器(我在 OS X 上)提交了 CRLF 行结尾。

现在,真正令我惊讶的是这不起作用:

$ git config core.autocrlf false
$ rm .git/index
$ git reset
Unstaged changes after reset:
M  test/functional/frontend/RedirectActionsTest.php

有人对问题所在以及如何解决有任何想法吗?我正在使用 Git 1.7.0.2。

Solved

It seems the remote repo contains two files named the same, except for the first letter. This caused a file overwrite on my system, which led to the issue below.

Update

It seems it has nothing to do with newlines, but I can't yet find an explanation. Here's what happens.

git status reports FileStartingWithCapitalLetter.php has been modified

On the other hand, browsing my case-insensitive file system, shows fileStartingWithCapitalLetter.php, which is actually starting with a lower-case "f".

git diff FileStartingWithCapitalLetter.php

shows this (the diff is hard to spot, it's the R in Redirect, which led me to think it has to do with CRLF):

diff --git a/test/functional/frontend/RedirectActionsTest.php b/test/functional/frontend/RedirectActionsTest.php
index 66e1fef..c574583 100644
--- a/test/functional/frontend/RedirectActionsTest.php
+++ b/test/functional/frontend/RedirectActionsTest.php
@@ -5,10 +5,10 @@ include(dirname(__FILE__).'/../../bootstrap/functional.php');
 $browser = new sfTestFunctional(new sfBrowser());
 
 $browser->
-  get('/Redirect/index')->
+  get('/redirect/index')->
 
   with('request')->begin()->
-    isParameter('module', 'Redirect')->
+    isParameter('module', 'redirect')->
     isParameter('action', 'index')->
   end()->

On the other hand, git diff fileStartingWithCapitalLetter.php (lower-case f), shows no changes.

What's the fix to this?

Old issue

I've cloned a git repo and then, immediately, executed git status. It was not a surprise to see that it reports modified files, as it happened to me before. There are CRLF line endings committed from a Windows machine (I'm on OS X).

Now, what really surprised me is that this didn't work:

$ git config core.autocrlf false
$ rm .git/index
$ git reset
Unstaged changes after reset:
M  test/functional/frontend/RedirectActionsTest.php

Does anyone have any ideas about what's wrong and how to solve it? I'm using Git 1.7.0.2.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

拥抱影子 2024-09-15 08:26:18

您可以尝试在全局级别设置此设置(注意:我也喜欢将其设置为 false

$ git config --global core.autocrlf false

,然后再次克隆以查看是否这个效果更好。

另一个需要注意的设置是:ignorecase true(也可以在全局级别设置)。
请参阅此SO问题作为示例,以及这个作为可以进行的说明错误的。

You could try to set this setting at the global level (Note: I also like having it set to false)

$ git config --global core.autocrlf false

and then clone again to see if this work better.

The other setting to watch out is: ignorecase true (also to set at the global level).
See this SO question as an example, and this one as an illustration of what can go wrong.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文