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
If none of the above usual ways help you, look at the call trace underneath this error message ("fatal: This operation . . ."
) and locate the script and line which is raising the actual error. Once you locate that error() call, disable it and see if the operation you are trying completes even with some warnings/messages - ignore them for now. If so, finally after completing it might mention the part of the operation that was not completed successfully. Now, address this part separately as applicable.
Relating above logic to my case, I was getting this error message "fatal: This operation . . ."
when I was trying to get the Android-x86 code with repo sync . . .
. and the call trace showed raise GitError("cannot initialize work tree")
as the error() call causing the above error message ("fatal: . . ."
). So, after commenting that GitError()
in .repo/repo/project.py
, repo sync . . .
continued and finally indicated error for three projects that were not properly synced. I just deleted their *.git
folders from their relevant paths in the Android-x86 source tree locally and ran repo sync . . .
again and tasted success!
If nothing else seems to work, double-check the path in git config core.worktree
. If that path doesn't point to your working directory, you may need to update it.
The way I got this error was that I created a Git repository on a network drive. It worked fine on one computer but returned this error on another. It turned out that I had the drive mapped to a Windows drive letter on the computer where I created it, but not on the other computer, and Git saved the path to the work tree as the mapped path and not the UNC path.
I had this issue, because .git/config
contained worktree = D:/git-repositories/OldName
. I just changed it into worktree = D:/git-repositories/NewName
I discovered that, because I used git gui, which showed a more detailed error message:
Edited the config file and changed bare = true to bare = false
Just clone the same project in another folder and copy the .git/ folder to your project.
Example
Create temp folder:
mkdir temp
switch to temp folder
cd temp/
clone the same project in the temp folder:
git clone [-b branchName] git@path_to_your_git_repository
copy .git folder to your projet:
cp -R .git/ path/to/your/project/
switch to your project and run git status
delete the temp folder if your are finished.
hope this will help someone
Also, you are probably inside the .git subfolder, move up one folder to your project root.