git status reports modified files in a freshly cloned repo

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 fetch a branch once with a normal name, and once with capital letter
  • git merge: filter files to avoid silly conflicts (like whitespace or case changes)
  • How can I do case insensitive git diffing?
  • git merge fails with “Untracked working tree file” on case change
  • git status showing two files modified after rename due to case
  • Git: File Rename
  • 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.

  • Git: How to prevent committing files that were modified just for debugging purposes?
  • Git clone without .git directory
  • git submodule not working after deleting
  • Why does Git allow pushing to a checked-out branch in an added worktree? How shall I recover?
  • How to change postgresql.conf default values on Openshift
  • How can I efficiently navigate a Git repo to follow project development?
  • One Solution collect form web for “git status reports modified files in a freshly cloned repo”

    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.

    Git Baby is a git and github fan, let's start git clone.