Git sees duplicated modified file

1.6k views Asked by At

In my repository there is a file (always that one) that always gives me trouble.
I'm working with coffeescript and generating the js with a grunt task.
For several times git status told me that this file was modified and needed to be added. The problem is that git sees this file duplicated:
enter image description here

Ok..so I try to add everything with git add :/ and all the files are added, included ONE copy of AreaChart.js while the other one remains modified and unstaged. If I try to checkout or add it manually, nothing happens, its status remains modified and unstaged.

Is it a git bug? How can I fix this?

EDIT:
actually git sees the same file with 2 different file names, that is AreaChart.js and Areachart.js.
If I ls I only see AreaChart.js (uppercase C) as it is supposed to be.

HINT:
If I add AreaChart.js (uppercase C) --> git adds Areachart.js (lowercase c)
If I add Areachart.js (lowercase c) --> git adds Areachart.js (lowercase c)

EDIT2:

  1. I found out the both files exist on the repository
  2. To my surprise I've found out that my filesystem (mac) is not case-sensitive, so if I touch test and touch Test only one file is created (or maybe both but I can see only one of them)
  3. The output git config core.ignorecase says true
2

There are 2 answers

9
Deepak On BEST ANSWER

Look again carefully

AreaChart.js 

and

Areachart.js

are different files. One has capital C and other has lower case c character.

Since Git is case sensitive, and your filesystem is case insensitive, you will only see one of these on your filesystem. If you only want one in Git, you should remove the other, with git rm --cached Areachart.js, and make sure that your updates are added via git add AreaChart.js.

3
Kristján On

Get gets confused when it's on case-insensitive file systems. Try:

git mv --force Areachart.js AreaChart.js