All o开发者_如何转开发f a sudden i am getting this git error: ""git status --porcelain failed"" when i do a git status.... whats up with that?
In my case, I have moved a submodule to another directory and I got that error message.
- After move submodule I edit
.gitsubmodule
to match current path of submodule. - Edit
<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 directory
fatal:git status --porcelain
failed in submoduleEdit
.git/modules/<pathOfSubmodule>/config
, theworktree
must match current path of submodule.Done.
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:
GIT COMMANDS
We divide git into high level ("porcelain") commands and low level ("plumbing") commands.
From the above posts, it would appear that, when git status
is run, it calls git status --porcelain
. man git-status
helpfully informs us what the --porcelain
flag is for:
--porcelain
Give the output in an easy-to-parse format for scripts. This is similar to the short output, but will remain stable across git versions and regardless of user configuration. See below for details.
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
status run "git status --porcelain" inside each populated submodule to see if it contains changes (link)
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? ;)
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.
cd /path/to/your/project/code
find ./ | grep ".git/index"
Once located delete ".git" all directories except the root one, but if you deleted it initialize your repo again
精彩评论