Search code examples
gitmsysgit

git init error: unable to create directory for .git/HEAD [inside htdocs/]


when I try to create a repo inside htdocs folder of my Apache installation (using Zend Server CE) git gives me this error:

  $ git init  
  error: unable to create directory for e:/WORK/Zend/Apache2/htdocs/gittest2/.git/HEAD

It works well outside htdocs/, but i would like to have repos inside this dir in order to work on them at the same time.

I have been using git bash with administrator privilages and AFAIR there's nothing else that could be wrong regarding privilages on Win machines.

Any help will be appreciated!

Using:

  • Win7 x64

  • git installed from msysGit -> Git-1.6.5.1-preview20091022.exe


[update]

  • as VonC suggested it might be a bug in this release of msysGit


Workaround

Use TortoiseGit to create a repo in the directory that's causing you problems. Good chance it will be successfull.

Sometimes Git GUI (from msysgit) will successfully create a 'troublesome' repo (worked on my last repo in this folder, not this one though).


Solution

  • It may be related to a bug with Git1.6.5.1 on 64 bit: this Japanese tweet mentions

    msysgit 1.6.5.1 だと"error: unable to create directory for [project]/.git/HEAD."とか言ってリポジトリが作れなかった。
    散々悩んだ後、1.6.3.2にバージョン下げたらあっさり成功

    Which Google ruffly translates as:

    it msysgit 1.6.5.1 "error: unable to create directory for [project] / .git / HEAD." Nor could they pull the repository including me.
    After the devastating agony, 1.6.3.2 version下Getara success lightly

    So a downgrade to 1.6.3.2 could be the answer here.
    But I did not found any opened bug supporting that.

    As they say: なんじゃこりゃ。(WTF) ;)

    Check also (if you are using a TortoiseGit), to use the 64-bit version and not the 32-bits one.