Git repo keeps showing modified files even in a fresh clone

后端 未结 1 1057
深忆病人
深忆病人 2021-01-01 15:26

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 be

相关标签:
1条回答
  • 2021-01-01 15:48

    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!

    0 讨论(0)
提交回复
热议问题