即使在新的克隆中,Git repo也会一直显示已修改的文件

时间:2013-07-10 04:27:37

标签: git

我遇到一个奇怪的问题,我之前从未遇到过Git回购。我没有编辑任何文件,但是当我运行git status时,我得到的结果显示在modified文件的整个文件夹中。奇怪的是,我甚至无法git add FILENAME或类似命令添加所有内容,当我运行git add命令时,它们不会被添加但是它们仍然显示为已修改。

更糟糕的是,我将我的github repo克隆到了一个新的目录中,问题仍然出现在那个回购中!所以我认为存在某种腐败或错误,因为似乎任何人都可以克隆我的回购并获得相同的结果!

有没有人见过这个,或者更好地了解如何解决?我已经尝试了几个命令来清除任何已更改或未更改的文件,但这些文件仍在git status运行时显示!

Github回购在这里https://github.com/jasondavis/zpanelx

enter image description here

1 个答案:

答案 0 :(得分:15)

更新

我弄清楚为什么只有Windows用户遇到问题:

$ 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

在Git索引文件中,存在大写和小写版本。 Linux用户必须检出这两个文件,甚至不注意,因为Linux区分大小写,并将它们视为两个独立的文件。

Windows在文件路径方面不区分大小写,因此它认为它们是同一个文件,并且它和/或Git在尝试将它们从索引中检入文件时会感到困惑系统。如果您在Windows上检查了两个版本的文件

,我不会感到惊讶
git config core.ignorecase false && \
git rm -r . && \
git reset --hard HEAD

应从repo中删除较旧的大写文件。向上游发出拉动请求以进行更改,我确信项目所有者将不胜感激。

旧答案

我尝试将(Windows)Git默认core.ignorecase设置为true:

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

这将删除所有大写文件(并在Git索引中暂存这些更改),所以之后我运行了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
#

正如您所看到的,大写文件是为提交暂存的,但是现在我们可以看到还有一些具有相同名称的小写文件,但它们还没有暂存。

然后我提交了大写文件的删除:

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

然后我做了硬复位:

$ git reset --hard head

然后我做了状态并且没有显示任何变化:

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

然后,如果我为其中一个小写文件执行find

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

它仍在工作目录中。不确定这是否是解决问题的正确方法。我还不确定问题的本质是什么。显然它与Windows中的文件大小写不敏感有关,但是为什么Windows用户遇到问题而Unix用户没有,我不确定。

旁注,现在the phpsysinfo project is on GitHub instead of an SVN repo,zpanelx作者可能有兴趣将其设为submodule。也许这将有助于避免将来出现这类问题?

实际上,也许你可以为项目业主做些什么?只需从您的仓库中删除整个./etc/apps/phpsysinfo,提交,然后再将其添加为子模块。推到原点,然后提出拉动请求,瞧!

相关问题