Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

git

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.

like image 600
Bialecki Avatar asked Sep 21 '09 21:09

Bialecki


People also ask

How do I fix a fatal Not a Git repository?

Check that you correctly created the repo. If the directory doesn't contain a . git repo, use git init to properly initialize the repo or clone an existing repo. Make sure your HEAD file contains the correct information on your current branch.

What is work tree in Git?

A Git worktree is a linked copy of your Git repository, allowing you to have multiple branches checked out at a time. A worktree has a separate path from your main working copy, but it can be in a different state and on a different branch.

What is fatal error in github?

What does “fatal: not a git repository” mean? This error means you attempted to run a Git command, but weren't inside a Git repository. Make sure you've: Navigated to the right directory.

What does Git clone mirror do?

Compared to --bare , --mirror not only maps local branches of the source to local branches of the target, it maps all refs (including remote-tracking branches, notes etc.) and sets up a refspec configuration such that all these refs are overwritten by a git remote update in the target repository.


1 Answers

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

like image 93
blj Avatar answered Sep 18 '22 14:09

blj