Search code examples
gitcase-sensitive

Git shows status clean, but checkout complains about overwriting untracked files


Firstly:

git status 

Result is clean.

Secondly

 git checkout fb/booking_interaction
 error: The following untracked working tree files would be overwritten by checkout:
 web/sites/all/modules/contrib/ckeditor/images/buttons/blockQuote.png

Thirdly, try to clear the untracked files. In the specified directory:

git clean -f .

Again, no changes and git checkout fails.

What is the problem?


Solution

  • The issue is due to case sensitivity of the file system.

    Looking at the problem. File listing:

    > ls
    imageButton.png
    imagebutton.png
    

    Check that git is set to case-sensitive

    > vi .git/config
    ignorecase = false
    

    This machine is case sensitive. The machine the change was made on must have been too.

    > git log
    removeformat.png - renamed from removeFormat.png. 
    

    Since I have changed ignorecase, git status now shows the change.

    > git status
    
    Untracked files:
    (use "git add <file>..." to include in what will be committed)
    
    blockQuote.png
    bulletedList.png
    

    Git clean also works as expected

    git clean -f .
    Removing blockQuote.png
    Removing bulletedList.png
    

    I can checkout the other branch without problems.