即使在新鲜的克隆中,Git仓库也不断显示修改后的文件 [英] Git repo keeps showing modified files even in a fresh clone

查看:84
本文介绍了即使在新鲜的克隆中,Git仓库也不断显示修改后的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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



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



Github回购在这里 而不是SVN repo ,zpanelx作者可能会对此感兴趣一个子模块。也许这将有助于避免将来出现这类问题?

实际上,也许你可以为项目所有者做些什么?只需从您的repo中删除整个 ./etc/apps/phpsysinfo ,然后将其作为子模块再次添加。推动你的来源,然后提出拉请求,瞧!!

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

解决方案

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!

这篇关于即使在新鲜的克隆中,Git仓库也不断显示修改后的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆