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

Jas*_*vis 16 git

我有一个奇怪的问题,我以前从未有过Git回购.我没有编辑任何文件但是当我运行时,git status我得到的结果显示在下面的图像中,显示了整个文件夹modified.奇怪的是,我甚git add FILENAME至不能或类似命令添加所有,当我运行git add命令时,他们没有添加,但他们仍然显示为修改.

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

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

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

在此输入图像描述

小智 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
Run Code Online (Sandbox Code Playgroud)

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

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

git config core.ignorecase false && \
git rm -r . && \
git reset --hard HEAD
Run Code Online (Sandbox Code Playgroud)

应从repo中删除较旧的大写文件.向上游提出改变请求,我相信项目业主会很感激.

老答案

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

$ git diff --name-only | xargs git rm -f
Run Code Online (Sandbox Code Playgroud)

这将删除所有大写文件(并在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
#
Run Code Online (Sandbox Code Playgroud)

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

那么我提交了大写文件的删除:

$ git commit -m "Delete upper-case files"
Run Code Online (Sandbox Code Playgroud)

然后我做了硬复位:

$ git reset --hard head
Run Code Online (Sandbox Code Playgroud)

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

$ git status
# On branch master
nothing to commit, working directory clean
Run Code Online (Sandbox Code Playgroud)

然后如果我find为一个小写文件做一个:

$ find . -name class.bat.inc.php
./etc/apps/phpsysinfo/plugins/BAT/class.bat.inc.php
Run Code Online (Sandbox Code Playgroud)

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

另外,现在phpsysinfo项目在GitHub 而不是SVN repo上,zpanelx作者可能有兴趣将它作为一个子模块.也许这有助于避免将来出现这类问题?

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