首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >即使在新克隆中,Git存储库也会继续显示修改过的文件

即使在新克隆中,Git存储库也会继续显示修改过的文件
EN

Stack Overflow用户
提问于 2013-07-10 12:27:37
回答 1查看 3.7K关注 0票数 21

我遇到了一个奇怪的问题,我以前从来没有遇到过Git repo。我没有编辑任何文件,但是当我运行git status时,我得到了下图中的结果,其中显示了modified文件的整个文件夹。奇怪的是,我甚至不能使用git add FILENAME或类似的命令来添加所有内容,当我运行git add命令时,它们不会被添加,但它们仍然显示为已修改。

更糟糕的是,我将我的github代码库克隆到一个新的目录中,问题仍然出现在该代码库中!所以我假设有某种类型的损坏或错误,因为似乎任何人都可以克隆我的repo并获得相同的结果!

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

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

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-07-10 14:59:13

更新

我明白了为什么只有Windows用户才会有问题:

代码语言:javascript
复制
$ 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上签出了该文件的两个版本,我不会感到惊讶

代码语言:javascript
复制
git config core.ignorecase false && \
git rm -r . && \
git reset --hard HEAD

应从存储库中删除较旧的大写文件。向上游提出变更请求,我相信项目所有者会很感激的。

老答案

我在(Windows) Git默认core.ignorecase设置为true的情况下尝试了一下:

代码语言:javascript
复制
$ git diff --name-only | xargs git rm -f

这将删除所有的大写文件(并将这些更改存放在Git索引中),所以之后我运行了git status

代码语言:javascript
复制
$ 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
#

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

因此,我提交了大写文件的删除:

代码语言:javascript
复制
$ git commit -m "Delete upper-case files"

然后我做了硬重置:

代码语言:javascript
复制
$ git reset --hard head

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

代码语言:javascript
复制
$ git status
# On branch master
nothing to commit, working directory clean

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

代码语言:javascript
复制
$ 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,提交,然后将其作为子模块再次添加。推送到你的原点,然后做一个拉取请求,瞧!

票数 19
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/17562439

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档