为什么我收到“git status --porcelain failed”?
突然间,当我执行 git status 操作时,我收到此 git 错误: ""git status --porcelain failed""...这是怎么回事?
All of a sudden i am getting this git error: ""git status --porcelain failed"" when i do a git status.... whats up with that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
就我而言,我已将子模块移动到另一个目录,并收到该错误消息。
.gitsubmodule
以匹配子模块的当前路径。/.git
,gitdir
必须匹配.git/modules/
。它有很多../../
,你可以使用ls
来查看。收到错误:-)
致命:无法 chdir 到
../
:没有这样的文件或目录致命:
git status --porcelain
在子模块中失败编辑
.git/modules//config
中失败,worktree
必须匹配子模块的当前路径。完成。
In my case, I have moved a submodule to another directory and I got that error message.
.gitsubmodule
to match current path of submodule.<currentPathOfSubmodule>/.git
, thegitdir
must match.git/modules/<pathOfSubmodule>
. It has a lot of../../
, you can usels
to check.Got that error :-)
fatal: Could not chdir to
../<someWhere>
: No such file or directoryfatal:
git status --porcelain
failed in submoduleEdit
.git/modules/<pathOfSubmodule>/config
, theworktree
must match current path of submodule.Done.
在一些类似的 StackOverflow 问题中可以找到此错误消息:此处、此处。谷歌搜索会显示包含此错误的邮件列表消息。没有人解释为什么会发生这种情况,所以我想我应该添加我发现的内容。
一些术语概述,来自
man git
页面:从上面的帖子可以看出,当运行 git status 时,它会调用 git status --porcelain 。
man git-status
有助于告诉我们--porcelain
标志的用途:因此,您遇到的问题与 git status 调用有关,该调用默认情况下尝试将其输出格式化为易于解析的格式。
从上面的帖子中,值得注意的是此处的答案和邮件列表内容,我建议,无论出于何种原因,您的 git 存储库都有变得腐败。如果您正在使用子模块,则其中一个子模块可能已损坏 - 这是相关的,因为
除非明确告知不要这样做。
至于为什么你似乎有一个损坏的git存储库?我不知道。 StackOverflow 上的其他几个人提到了覆盖、移动、替换或通常摆弄其存储库中的
.git
目录。幸运的是,你有备份,对吧? ;)This error message is found in some similar StackOverflow questions: here, here. Googling brings up a mailing list message with this error. Nobody has given an explanation why it occurs, so I thought I'd add what I've found.
Some overview of terminology, from the
man git
page:From the above posts, it would appear that, when
git status
is run, it callsgit status --porcelain
.man git-status
helpfully informs us what the--porcelain
flag is for:So the issue you have is related to the
git status
call, which is by default trying to format its output into something easy to parse.From the above posts, noticably the answers here and the mailing list contentets, I would suggest that, for whatever reason, your git repository has become corrupted. If you're using submodules, it's possible one of those has become corrupted - this is relevant because
unless explicitly told not to do so.
As to why you seem to have a corrupted git repository? I don't know. Several other people on StackOverflow have mentioned overwriting, moving, replacing, or generally fiddling with
.git
directories in their repositories. Luckily, you have a backup, though, right? ;)通常,git 在项目的根目录 (.git/) 中创建一个隐藏目录。
当您在 CMS 上工作时,您可能会安装带有 .git/ 目录的模块/插件,其中包含特定模块/插件的 git 元数据
如果您不这样做想要使用 git 的子模块功能,最快的解决方案是删除除根 git 元数据目录之外的所有 .git 目录。
如果这样做,git 不会将这些模块视为项目子模块。
一旦找到,删除“.git”除根目录之外的所有目录,但如果删除它,请再次初始化您的存储库
Usually, git creates a hidden directory in project's root directory (.git/)
When you're working on a CMS, its possible you install modules/plugins carrying .git/ directory with git's metadata for the specific module/plugin
If you do not want to use git's submodules feature, quickest solution delete all .git directories except root git metadata directory.
If you do so, git will not consider those modules as project submodules.
Once located delete ".git" all directories except the root one, but if you deleted it initialize your repo again