Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

All of a sudden i am getting this git error: ""git status --porcelain failed"" when i do a git status.... whats up with that?

like image 332
Doz Avatar asked Jul 31 '11 09:07

Doz


People also ask

What is Git status porcelain?

Porcelain Format Version 1 Version 1 porcelain format is similar to the short format, but is guaranteed not to change in a backwards-incompatible way between Git versions or based on user configuration. This makes it ideal for parsing by scripts.

How do I add a submodule to a Git repository?

In order to add a Git submodule, use the “git submodule add” command and specify the URL of the Git remote repository to be included as a submodule. When adding a Git submodule, your submodule will be staged. As a consequence, you will need to commit your submodule by using the “git commit” command.


2 Answers

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.

like image 92
cakyus Avatar answered Oct 08 '22 17:10

cakyus


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? ;)

like image 30
simont Avatar answered Oct 08 '22 16:10

simont