git status 将未修改的文件显示为已修改,并且 git diff 无法对它们进行哈希处理

git status shows untouched files as modified, and git diff cannot hash them

Ubuntu16.04,git版本 2.7.4

我一直在本地开发一些也远程托管的代码。 今天,偶尔还有其他几次,会发生以下情况。 其他时候只是怀疑地等待就消失了,但现在它似乎是持久的。

第一步,通过:同步当前分支与远程

git pull
Already up-to-date.

第 2 步,失败:检查状态和新修改的文​​件突然出现

git status

On branch [mybranch]
Your branch is up-to-date with 'origin/[mybranch]'.
Changes not staged for commit:
(use "git add ..." to update what will be committed)
(use "git checkout -- ..." to discard changes in working directory)

some 30+ files are given as modified, even though I don't quite think they have been changed

(重启后变成了15,不规律。 再次重启后,3。 请注意:不对文件执行任何操作)

第 3 步:询问有什么区别

用几个文件探测情况,我得到

git diff ../../[directory]/[directory]/[file].md5
error: short read No such file or directory
error: [directory]/[directory]/[file].md5: failed to insert into database
fatal: cannot hash [directory]/[directory]/[file].md5

研究

想到 Git shows all files as modified after changing file permission,我认为最近没有更改权限。这些文件已经完全僵化了。

问题

造成这种情况的可能原因是什么,如何防止这种情况再次发生?

为什么它有时会自动自愈,有时会持续存在?

Ubuntu 16.04,git 版本 2.7.4,Doxygen 1.8.12

诊断

违规文件是 Doxygen 文档的元素,存储在一个包含 507M 文件和 19,415 个文件的目录中。 可能这混淆了 git 中的簿记, 我的第一个假设。

治愈

Doxygen 在配置文件中有一个选项可以将文件分布在不同的目录中,实际上其树结构类似于 git

的方式

# If the CREATE_SUBDIRS tag is set to YES then doxygen will create 4096 sub-
# directories (in 2 levels) under the output directory of each output format and
# will distribute the generated files over these directories. Enabling this
# option can be useful when feeding doxygen a huge amount of source files, where
# putting all generated files in the same directory would otherwise causes
# performance problems for the file system.
# The default value is: NO.

CREATE_SUBDIRS = YES

我已将其设置为是,并循环了

git status; git add .; git commit -m ...; git push

几次,直到我得到:

git status
On branch [mybranch]
Your branch is up-to-date with 'origin/[mybranch]'.
nothing to commit, working directory clean

解决了上面第 2 步中的问题。

琐事

出于好奇 reader 我发现这些其他帖子有点 证实了我的方法,至少给我一些值得尝试的线索:

任何 expert/experienced 希望提高此答案质量的人,请成为我的客人。