22

I am having a strange issue I have never had before with a Git repo. I have not edited any files however when I run git status I get the result in the image below that shows a whole folder of modified files. The strange thing is, I cannot even git add FILENAME or similar command to add all, when I run a git add command they do not get added but yet they still show up as modified.

To make it even worse, I cloned my github repo into a new fresh directory and the issue still appears in that repo! SO I assume there is some sort of corruption or something wrong, since it appears anyone can clone my repo and get the same result!

Has anyone ever seen this, or better have a clue as to how to resolve? I have tried several commands to clear out any changed or unchanged files but these files still show up when git status is ran!

The Github repo is here https://github.com/jasondavis/zpanelx

enter image description here

JasonDavis
  • 48,204
  • 100
  • 318
  • 537
  • 1
    http://stackoverflow.com/questions/15752026/git-on-windows-shows-modified-files-all-the-time-even-for-newly-cloned-repo not working ? – d.danailov Jul 10 '13 at 04:31
  • I do not have this problem when cloning your repo. – Max Jul 10 '13 at 04:37
  • 3
    +1 for actually giving us a link to the repo so we can check it out ourselves and see what's going on. So helpful for debugging! –  Jul 10 '13 at 04:45
  • @d.danailov thanks for the link, I do think that could be the issue however the answer `git config --global core.autocrlf true` did not help my situation, thanks for sharing though – JasonDavis Jul 10 '13 at 04:45
  • @Max thanks for testing, so it is something to do with my windows machine or settings. – JasonDavis Jul 10 '13 at 04:46
  • 1
    I have the same issue on my machine, I'm using msysgit 1.8.3 on Windows 8. I had `core.autocrlf false` first, then I ran `git config core.autocrlf true && git rm -r --cached * && git reset --hard head`, and problem still persists. –  Jul 10 '13 at 04:51
  • @Cupcake I am glad that at least i'm not the only one with the issue! It's so bizarre though – JasonDavis Jul 10 '13 at 04:52
  • It has nothing to do with line endings, there are case and text changes in the files. Can you show us some text diffs to confirm? I'm not sure why they're there, all I did was check the repo out, and I didn't make any modifications. –  Jul 10 '13 at 04:58
  • This is the upstream repo for the project https://github.com/bobsta63/zpanelx I know that the owner just updated this folder that I am having the issue with, they had just updated that software to a newer version so when I pulled down the changes, it had to remove/add/merger the files and that's when I noticed this issue. I have personally never looked at these particular files until now – JasonDavis Jul 10 '13 at 05:02
  • 1
    @Cupcake Think I found the issue https://github.com/gitextensions/gitextensions/issues/1614 doesn't look like theres an easy solution though – JasonDavis Jul 10 '13 at 05:08
  • @jasondavis the problem exists with the upstream repo too though. Also, I tried `git rm -r --cached * && git reset --hard head` with both `core.ignorecase` set to both true and false, still the same result. When I diff, there are actual significant text changes, it's not just case. Maybe check the upstream issue list? –  Jul 10 '13 at 05:22
  • @Cupcake yeah this isn't looking good, I know the upstream author has no clue about this, he just made the commit 13 hours ago and he doesn't know this problem exists yet. I am pretty sure the issue now is there are 2 copies in the Git index for those particular files – JasonDavis Jul 10 '13 at 05:26
  • So wait, how come @Max did not have any problems? What version of Git are you using Max, and on what operating system? –  Jul 10 '13 at 05:34
  • Hey, I take it back, the diff shows case changes in the text that describes the version of the file `etc/apps/phpsysinfo/plugins/Quotas/class.Quotas.inc.php` to lower case. You mentioned it's a 3rd party library? It used to be in an SVN repo at http://phpsysinfo.sourceforge.net, but now it can be found on [GitHub](https://github.com/rk4an/phpsysinfo). –  Jul 10 '13 at 06:23
  • Found this, not sure if it will help: [Git - change case of a file on windows?](http://stackoverflow.com/questions/1793735/git-change-case-of-a-file-on-windows). Anyways, you were right the first time @jasondavis, there are case changes to the file names that are confusing Git on Windows. Still trying to figure out how to fix. –  Jul 10 '13 at 06:37
  • I've tried on Linux (git 1.7.10) and "git status" doesn't show any modified file. Have you inspected if it is just related to a change in file permissions ? – Claudio Jul 10 '13 at 06:54

1 Answers1

20

Update

I figured out why only Windows users are having problems:

$ git ls-files | grep -i class.bat
etc/apps/phpsysinfo/plugins/BAT/class.BAT.inc.php
etc/apps/phpsysinfo/plugins/bat/class.bat.inc.php

In the Git index file, both the upper case and lower case versions exist. Linux users must be getting both files checked out and don't even notice, because Linux is case-sensitive and treats them as two separate files, as they are.

Windows isn't case-sensitive with regard to file paths though, so it thinks they're the same file, and it and/or Git is getting confused when it tries to check them both out of the index into the file system. I wouldn't be surprised if you get both versions of the file checked out on Windows if you do

git config core.ignorecase false && \
git rm -r . && \
git reset --hard HEAD

The older, upper-case files should be deleted from the repo. Make a pull-request to upstream for the changes, I'm sure the project owners will be grateful.

Old Answer

I tried this out with the (Windows) Git default core.ignorecase set to true:

$ git diff --name-only | xargs git rm -f

That will delete all the upper-case files (and stage those changes in the Git index), so afterwards I ran git status:

$ git status
# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#       deleted:    etc/apps/phpsysinfo/includes/mb/class.Coretemp.inc.php
#       deleted:    etc/apps/phpsysinfo/includes/mb/class.HDDTemp.inc.php
#       deleted:    etc/apps/phpsysinfo/includes/mb/class.HWSensors.inc.php
#       deleted:    etc/apps/phpsysinfo/includes/mb/class.Healthd.inc.php
#       deleted:    etc/apps/phpsysinfo/includes/mb/class.IPMI.inc.php
#       deleted:    etc/apps/phpsysinfo/includes/mb/class.K8Temp.inc.php
#       deleted:    etc/apps/phpsysinfo/includes/mb/class.LMSensors.inc.php
#       deleted:    etc/apps/phpsysinfo/includes/mb/class.MBM5.inc.php
#       deleted:    etc/apps/phpsysinfo/includes/mb/class.MBMon.inc.php
#       deleted:    etc/apps/phpsysinfo/includes/mb/class.Sensors.inc.php
#       deleted:    etc/apps/phpsysinfo/includes/ups/class.Apcupsd.inc.php
#       deleted:    etc/apps/phpsysinfo/includes/ups/class.Nut.inc.php
#       deleted:    etc/apps/phpsysinfo/plugins/BAT/class.BAT.inc.php
#       deleted:    etc/apps/phpsysinfo/plugins/BAT/js/BAT.js
#       deleted:    etc/apps/phpsysinfo/plugins/BAT/lang/cz.xml
#       deleted:    etc/apps/phpsysinfo/plugins/BAT/lang/en.xml
#       deleted:    etc/apps/phpsysinfo/plugins/BAT/lang/fr.xml
#       deleted:    etc/apps/phpsysinfo/plugins/MDStatus/class.MDStatus.inc.php
#       deleted:    etc/apps/phpsysinfo/plugins/MDStatus/css/MDStatus.css
#       deleted:    etc/apps/phpsysinfo/plugins/MDStatus/js/MDStatus.js
#       deleted:    etc/apps/phpsysinfo/plugins/MDStatus/lang/cz.xml
#       deleted:    etc/apps/phpsysinfo/plugins/MDStatus/lang/de.xml
#       deleted:    etc/apps/phpsysinfo/plugins/MDStatus/lang/en.xml
#       deleted:    etc/apps/phpsysinfo/plugins/MDStatus/lang/fr.xml
#       deleted:    etc/apps/phpsysinfo/plugins/PS/class.PS.inc.php
#       deleted:    etc/apps/phpsysinfo/plugins/PS/js/PS.js
#       deleted:    etc/apps/phpsysinfo/plugins/PS/lang/cz.xml
#       deleted:    etc/apps/phpsysinfo/plugins/PS/lang/de.xml
#       deleted:    etc/apps/phpsysinfo/plugins/PS/lang/en.xml
#       deleted:    etc/apps/phpsysinfo/plugins/PS/lang/fr.xml
#       deleted:    etc/apps/phpsysinfo/plugins/PSStatus/class.PSStatus.inc.php
#       deleted:    etc/apps/phpsysinfo/plugins/PSStatus/css/PSStatus.css
#       deleted:    etc/apps/phpsysinfo/plugins/PSStatus/js/PSStatus.js
#       deleted:    etc/apps/phpsysinfo/plugins/PSStatus/lang/cz.xml
#       deleted:    etc/apps/phpsysinfo/plugins/PSStatus/lang/de.xml
#       deleted:    etc/apps/phpsysinfo/plugins/PSStatus/lang/en.xml
#       deleted:    etc/apps/phpsysinfo/plugins/PSStatus/lang/fr.xml
#       deleted:    etc/apps/phpsysinfo/plugins/Quotas/class.Quotas.inc.php
#       deleted:    etc/apps/phpsysinfo/plugins/Quotas/css/Quotas.css
#       deleted:    etc/apps/phpsysinfo/plugins/Quotas/js/Quotas.js
#       deleted:    etc/apps/phpsysinfo/plugins/Quotas/lang/cz.xml
#       deleted:    etc/apps/phpsysinfo/plugins/Quotas/lang/de.xml
#       deleted:    etc/apps/phpsysinfo/plugins/Quotas/lang/en.xml
#       deleted:    etc/apps/phpsysinfo/plugins/Quotas/lang/fr.xml
#       deleted:    etc/apps/phpsysinfo/plugins/SMART/class.SMART.inc.php
#       deleted:    etc/apps/phpsysinfo/plugins/SMART/css/SMART.css
#       deleted:    etc/apps/phpsysinfo/plugins/SMART/js/SMART.js
#       deleted:    etc/apps/phpsysinfo/plugins/SMART/lang/cz.xml
#       deleted:    etc/apps/phpsysinfo/plugins/SMART/lang/en.xml
#       deleted:    etc/apps/phpsysinfo/plugins/SMART/lang/fr.xml
#       deleted:    etc/apps/phpsysinfo/plugins/SNMPPInfo/class.SNMPPInfo.inc.php
#       deleted:    etc/apps/phpsysinfo/plugins/SNMPPInfo/js/SNMPPInfo.js
#       deleted:    etc/apps/phpsysinfo/plugins/SNMPPInfo/lang/cz.xml
#       deleted:    etc/apps/phpsysinfo/plugins/SNMPPInfo/lang/en.xml
#       deleted:    etc/apps/phpsysinfo/plugins/SNMPPInfo/lang/pl.xml
#       deleted:    etc/apps/phpsysinfo/plugins/UpdateNotifier/class.UpdateNotifier.inc.php
#       deleted:    etc/apps/phpsysinfo/plugins/UpdateNotifier/js/UpdateNotifier.js
#       deleted:    etc/apps/phpsysinfo/plugins/UpdateNotifier/lang/cz.xml
#       deleted:    etc/apps/phpsysinfo/plugins/UpdateNotifier/lang/en.xml
#       deleted:    etc/apps/phpsysinfo/plugins/UpdateNotifier/lang/fr.xml
#       deleted:    etc/apps/phpsysinfo/plugins/UpdateNotifier/lang/pl.xml
#
# Changes not staged for commit:
#   (use "git add/rm <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#       deleted:    etc/apps/phpsysinfo/includes/mb/class.coretemp.inc.php
#       deleted:    etc/apps/phpsysinfo/includes/mb/class.hddtemp.inc.php
#       deleted:    etc/apps/phpsysinfo/includes/mb/class.healthd.inc.php
#       deleted:    etc/apps/phpsysinfo/includes/mb/class.hwsensors.inc.php
#       deleted:    etc/apps/phpsysinfo/includes/mb/class.ipmi.inc.php
#       deleted:    etc/apps/phpsysinfo/includes/mb/class.k8temp.inc.php
#       deleted:    etc/apps/phpsysinfo/includes/mb/class.lmsensors.inc.php
#       deleted:    etc/apps/phpsysinfo/includes/mb/class.mbm5.inc.php
#       deleted:    etc/apps/phpsysinfo/includes/mb/class.mbmon.inc.php
#       deleted:    etc/apps/phpsysinfo/includes/mb/class.sensors.inc.php
#       deleted:    etc/apps/phpsysinfo/includes/ups/class.apcupsd.inc.php
#       deleted:    etc/apps/phpsysinfo/includes/ups/class.nut.inc.php
#       deleted:    etc/apps/phpsysinfo/plugins/bat/class.bat.inc.php
#       deleted:    etc/apps/phpsysinfo/plugins/bat/js/bat.js
#       deleted:    etc/apps/phpsysinfo/plugins/bat/lang/cz.xml
#       deleted:    etc/apps/phpsysinfo/plugins/bat/lang/en.xml
#       deleted:    etc/apps/phpsysinfo/plugins/bat/lang/fr.xml
#       deleted:    etc/apps/phpsysinfo/plugins/mdstatus/class.mdstatus.inc.php
#       deleted:    etc/apps/phpsysinfo/plugins/mdstatus/css/mdstatus.css
#       deleted:    etc/apps/phpsysinfo/plugins/mdstatus/js/mdstatus.js
#       deleted:    etc/apps/phpsysinfo/plugins/mdstatus/lang/cz.xml
#       deleted:    etc/apps/phpsysinfo/plugins/mdstatus/lang/de.xml
#       deleted:    etc/apps/phpsysinfo/plugins/mdstatus/lang/en.xml
#       deleted:    etc/apps/phpsysinfo/plugins/mdstatus/lang/fr.xml
#       deleted:    etc/apps/phpsysinfo/plugins/ps/class.ps.inc.php
#       deleted:    etc/apps/phpsysinfo/plugins/ps/js/ps.js
#       deleted:    etc/apps/phpsysinfo/plugins/ps/lang/cz.xml
#       deleted:    etc/apps/phpsysinfo/plugins/ps/lang/de.xml
#       deleted:    etc/apps/phpsysinfo/plugins/ps/lang/en.xml
#       deleted:    etc/apps/phpsysinfo/plugins/ps/lang/fr.xml
#       deleted:    etc/apps/phpsysinfo/plugins/psstatus/class.psstatus.inc.php
#       deleted:    etc/apps/phpsysinfo/plugins/psstatus/css/psstatus.css
#       deleted:    etc/apps/phpsysinfo/plugins/psstatus/js/psstatus.js
#       deleted:    etc/apps/phpsysinfo/plugins/psstatus/lang/cz.xml
#       deleted:    etc/apps/phpsysinfo/plugins/psstatus/lang/de.xml
#       deleted:    etc/apps/phpsysinfo/plugins/psstatus/lang/en.xml
#       deleted:    etc/apps/phpsysinfo/plugins/psstatus/lang/fr.xml
#       deleted:    etc/apps/phpsysinfo/plugins/quotas/class.quotas.inc.php
#       deleted:    etc/apps/phpsysinfo/plugins/quotas/css/quotas.css
#       deleted:    etc/apps/phpsysinfo/plugins/quotas/js/quotas.js
#       deleted:    etc/apps/phpsysinfo/plugins/quotas/lang/cz.xml
#       deleted:    etc/apps/phpsysinfo/plugins/quotas/lang/de.xml
#       deleted:    etc/apps/phpsysinfo/plugins/quotas/lang/en.xml
#       deleted:    etc/apps/phpsysinfo/plugins/quotas/lang/fr.xml
#       deleted:    etc/apps/phpsysinfo/plugins/smart/class.smart.inc.php
#       deleted:    etc/apps/phpsysinfo/plugins/smart/css/smart.css
#       deleted:    etc/apps/phpsysinfo/plugins/smart/js/smart.js
#       deleted:    etc/apps/phpsysinfo/plugins/smart/lang/cz.xml
#       deleted:    etc/apps/phpsysinfo/plugins/smart/lang/en.xml
#       deleted:    etc/apps/phpsysinfo/plugins/smart/lang/fr.xml
#       deleted:    etc/apps/phpsysinfo/plugins/snmppinfo/class.snmppinfo.inc.php
#       deleted:    etc/apps/phpsysinfo/plugins/snmppinfo/js/snmppinfo.js
#       deleted:    etc/apps/phpsysinfo/plugins/snmppinfo/lang/cz.xml
#       deleted:    etc/apps/phpsysinfo/plugins/snmppinfo/lang/en.xml
#       deleted:    etc/apps/phpsysinfo/plugins/snmppinfo/lang/pl.xml
#       deleted:    etc/apps/phpsysinfo/plugins/updatenotifier/class.updatenotifier.inc.php
#       deleted:    etc/apps/phpsysinfo/plugins/updatenotifier/js/updatenotifier.js
#       deleted:    etc/apps/phpsysinfo/plugins/updatenotifier/lang/cz.xml
#       deleted:    etc/apps/phpsysinfo/plugins/updatenotifier/lang/en.xml
#       deleted:    etc/apps/phpsysinfo/plugins/updatenotifier/lang/fr.xml
#       deleted:    etc/apps/phpsysinfo/plugins/updatenotifier/lang/pl.xml
#

As you can see, the upper-case files are staged for commit, but now we can see that there are also lower-case files with the same names, but they're not staged yet.

So then I committed the deletions of the upper-case files:

$ git commit -m "Delete upper-case files"

Then I did hard reset:

$ git reset --hard head

Then I did status and it shows no changes:

$ git status
# On branch master
nothing to commit, working directory clean

And then if I do a find for one of the lower-case files:

$ find . -name class.bat.inc.php
./etc/apps/phpsysinfo/plugins/BAT/class.bat.inc.php

It's still in the working directory. Not sure if this is the right way to fix the problem though. I'm still not even sure what the nature of the problem is. Obviously it has something to do with file case-insensitivity in Windows, but why Windows users are having problems and Unix users are not, I'm not sure.

On a side note, now that the phpsysinfo project is on GitHub instead of an SVN repo, the zpanelx authors might be interested in making it a submodule. Maybe that will help avoid this sort of issue in the future?

Actually, maybe that's something that you can do for the project owners? Just delete the whole ./etc/apps/phpsysinfo from your repo, commit, then add it again as a submodule. Push to your origin, then make a pull-request, and voila!

  • Thanks for all your work, the owner actually ended up fixing it himself by simply deleting the files and then reading them, basically the same thing you have done here though. This will surely be helpful to other users in the future I am sure! And that is a good idea of using a submodule – JasonDavis Jul 10 '13 at 16:02
  • Thank you very much, this windows file issue was plaguing us, I really appreciate your research and help, and the fact you came back and updated the answer to be even more useful! thanks again! – DrCord Mar 20 '15 at 16:17