Intellij IDEA: fatal: invalid version of 'HEAD'

I worked with my git project inside Intellij IDEA and everything was fine. Then I created a new repository that included the current one. I updated the Version Control section in Preferences to point to a new root folder where the IDE showed me two "Git Roots". I turned on both.

Result: IDEA does not track any changes in files and an error pops up: fatal: bad revision 'HEAD' . The IDE also states that all of my files are not versioned. Any ideas? Thanks.

+6
source share
4 answers

You cannot just create the git directory in the parent directory of the repository and expect the work to work. This will help you find out what you are actually trying to achieve , but the wild hunch is that you probably want to take a look at the git submodules .

+4
source

This usually happens because the .git directory is nested in the actual workspace, so you will have to delete the .git .

0
source

Good. Some time ago, since it was open, but it is not, you can have a git nested structure in some repository that I worked on in the git folder, like in every plugin folder. However, subfolders are ignored by the gitignore file. This is another problem. My solution was to delete the .git folder and start over as it was a new project, in my case I renamed the directory and the project since I had a typo in the name.

0
source

This solved the problem in my case:

  1. Unregister the problematic version control root in the IDE settings and click OK:

    enter image description here

  2. Open it again and add (register) it:

    enter image description here

0
source

All Articles