2

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
Leonardo
  • 4,046
  • 5
  • 44
  • 85
  • 2
    Those filenames are actually different: the second has a lower-case 'c'. Are you , or is some other developer, working on Windows? – ChrisGPT was on strike Jun 15 '15 at 15:49
  • Can you try a `git add -A :/` That could record an addition *and* a deletion, to take into account a possible case change during the generation. – VonC Jun 15 '15 at 15:49
  • @Chris you are right, but a `ls` inside the directory tells me that only one exists, the one with uppercase C: `AreaChart.js` as it supposed to be, so it is git that sees 2 files! – Leonardo Jun 15 '15 at 15:54
  • I've made an edit about the two filenames and the changing `c` – Leonardo Jun 15 '15 at 16:01
  • @Leonardo, if you're on Windows you may only see one file even if both exist. The underlying NTFS filesystem is case-sensitive, but Windows itself is not. This can lead to weirdness like you're experiencing. – ChrisGPT was on strike Jun 15 '15 at 16:03
  • @Chris nope, I'm on a mac – Leonardo Jun 15 '15 at 16:04
  • 2
    What's the output of `git config core.ignorecase`? – Edward Thomson Jun 15 '15 at 16:45
  • @EdwardThomson the result of this command is `true`! Also, with my immense surprise I've found out that my fs is NOT case-sensitive, if I `touch hello` and `touch Hello` only one file is created – Leonardo Jun 16 '15 at 07:56

2 Answers2

3

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.

Edward Thomson
  • 74,857
  • 14
  • 158
  • 187
Deepak
  • 1,503
  • 3
  • 22
  • 45
  • Is your repo on github? If so I can try by downloading it. – Deepak Jun 15 '15 at 16:06
  • 1
    @Leonardo I'm not sure what you're saying "nope" to. Did you try this? If you only want one in your repository, you need to delete the other (`git rm --cached Areachart.js`, for example) – Edward Thomson Jun 15 '15 at 16:06
  • @EdwardThomson `git rm --cached Areachart.js` fixed the problem but again, `ls -a` showed me only one existing file, the one with the uppercase. Could you put this as an answer? – Leonardo Jun 15 '15 at 16:12
  • Also suppose you make two files add to git. Then delete one from filesystem. Git will show you 2 files but your filesystem just 1 unless you remove it from git also or checkout from from got to get it back. Something similar might have occurred in your case by chance – Deepak Jun 15 '15 at 16:17
  • ok, this is still not the solution, sorry..I have tried to modify again the original `AreaChart.coffee`, then after compiling it git keeps on seeing (randomly) sometimes the the two different js files, sometimes only one (correct) file. Again, in my file system I only have One of them `AreaChart.js` – Leonardo Jun 15 '15 at 16:27
  • @Leonardo Are you specifying the case correctly for all your operations? What do you mean "git keeps on seeing" these files? Untracked or staged? If the latter, how did you run `git add`? – Edward Thomson Jun 15 '15 at 16:43
  • @EdwardThomson git tells me that those two files are modified (tracked). One of them actually exists phisically, the other one doesn't exists on my file systems – Leonardo Jun 15 '15 at 22:07
  • How did those changes get staged? Did you run `git add`? Or is something else doing it for you? If so, what's that other thing? – Edward Thomson Jun 15 '15 at 22:10
  • @EdwardThomson please read the Hint on my question, I can't get them both staged, only one. I'm seriously thinking it is a filesystem case-sensitive problem. Now I'm not on the faulty mac, I'll check again tomorrow – Leonardo Jun 15 '15 at 22:26
3

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

git mv --force Areachart.js AreaChart.js
Kristján
  • 18,165
  • 5
  • 50
  • 62