git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Having an invalid HEAD file causes git not to recognize the repository

From
EEEgon Elbre <egonelbre@gmail.com>
Date
Aug 17, 2012, 11:42 UTC
Message-ID
<CANtNKfp+9HpvWkAO0vrm84oMiJNvjFg9T-UtNQko+ABHhEWj6w@mail.gmail.com>

Having an invalid HEAD file causes git not to recognize the repository and will cause an invalid message "fatal: Not a git repository (or any of the parent directories): .git" although there is a .git folder and everything seems okay in it. Solution was just to change HEAD to a valid ref/hash.

I ran into this problem when I had a BSOD during a rebase (ignore that I'm having to use Windows). This meant that only half of the hash got written into HEAD and all git commands I tried failed.

Not sure whether it's useful to add a better message for this case, but at least if somebody stumbles on it again, maybe they can find this text.

+ egon
Next: Jeff King
Message 1 of 3 in “Having an invalid HEAD file causes git not to recognize the repository”
  1. Egon ElbreAug 17, 2012
  2. Jeff KingAug 21, 2012
  3. Egon ElbreAug 21, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.