Git update problem: Can't update: no current branch: You are in 'detached HEAD' state

Hi there.
I'm facing a problem with Git support in PHPStorm - I don't know if I am doing something wrong or is it a bug, so after finding nothing simillar, I decided to start a discussion.

I have PhpStorim 3.0.3 running on Linux OS and when trying to update project from VCS (Git) I am getting the error as in the topic: "Can't update: no current branch: You are in 'detached HEAD' state, which means that you're not on any branch in Git repository. Checkout a branch to make update possible.".
I am no master in git, but I have read a little about detached HEAD. And still I can't fix it.
This can bo PhpStorm problem (or it's git module) because from within command line there is no problem with fetching and/or pulling. Moreover, the message provided by IDE says: "(...) you're not on any branch in Git repository. Checkout a branch to make update possible.", but it shows my local branch in every window/popup or status bar in the ID (like the one in lower right corner, just before the read-only toggle icon and inspection profile button).

So what is the problem?
Right now I have to make updates manually from command line. Pushing commits to remote branches works properly.

Comment actions Permalink

Have you only 1 Git repository in the project?

What happens if you execute 'git branch' in the command line?

Comment actions Permalink

Thanks for the reply!

There are more than one repository in the project, but only one is the "main" one, others are utilized via git submodule command.
'git branch' executed from the command line gives me list of three branches, where the first one is marked by star (*) and coloured green, like:

* 2.0/develop

Comment actions Permalink

Probably the submodules are the root cause.

Please check for each repository, which branch are you on. Maybe you're in detached HEAD in one of the submodules.

You may also want to check PhpStorm EAP ( - we still don't fully support submodules, but working with multiple roots was improved.

Comment actions Permalink

Thanks for the help, Kirill!
Most of submodules were, indeed, in detached HEAD state. I have fixed it by switching them to proper branches. But then I received other message on my screen:

Invalid Git Roots: Some configured Git VCS roots are not under Git or have Git repositories in subdirectories without a configured VCS root. Configure...

Now every time I open this project in PHPStorm I have this error and clicking "Configure" displays a window titled "Fix Git VCS Roots" with all the submodules repositories listed as new (bold).

And then I have to go into File/Settings/Project Settings/Version Control and remove all the entries but the main one. It is, unfortunatelly, not stored, and I have to do this every time I open the project. Is there anything I can do about it?

Comment actions Permalink

The "invalid git roots" error is already fixed. So please try new EAP builds - it should help.


Please sign in to leave a comment.