开发者

Why am i getting "git status --porcelain failed"? [duplicate]

This question already has answers here: Why do I get "fatal: git status --porcelain failed"? (13 answers) Closed 5 years ago.

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.

  1. After move submodule I edit .gitsubmodule to match current path of submodule.
  2. Edit <currentPathOfSubmodule>/.git , the gitdir must match .git/modules/<pathOfSubmodule>. It has a lot of ../../, you can use ls to check.
  3. Got that error :-)

    fatal: Could not chdir to ../<someWhere>: No such file or directory
    fatal: git status --porcelain failed in submodule

  4. Edit .git/modules/<pathOfSubmodule>/config, the worktree must match current path of submodule.

  5. 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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜