Why am I getting the message, "fatal: This operation must be run in a work tree?" Ask Question

Why am I getting the message,

Just installed git on Windows. I set the GIT_DIR variable to be c:\git\ and verified that this environment variable is maintained by cygwin (i.e. echo $GIT_DIR is what it should be). I went to the folder that I wanted to create the git repository for, let's say c:\www, and then ran:

git init
git add .

Then I get the error:

fatal: This operation must be run in a work tree

I'm not sure what went wrong, but the c:\git directory has a config file that says:

[core]
    repositoryformatversion = 0
    filemode = false
    bare = true
    symlinks = false
    ignorecase = true

I'm pretty sure this shouldn't be bare and that's our problem.

ベストアンサー1

Also, you are probably inside the .git subfolder, move up one folder to your project root.

おすすめ記事