'Git status fatal error: working tree directory

When trying to git status I get the following

git status fatal: not a git repository: D:/path/path/path/.git/worktrees/horus_app_v100

the path worktrees/horus_app_v100 doesn't exist

I recently deleted a worktree named horus_app_v100 and its branch, but it seems that there is something connected, so I can't git status.

There is no worktree called horus_app_v100, cuz I deleted, there is only my main worktree (1 worktree), but git status seems to be trying to reach a directory/worktree that doesn't even exist



Solution 1:[1]

There was a file (which I don't know how was there, maybe I created trying to fix the problem) called .git [ file, not the folder]. This file was inside one of the child folders of my project. The content of the file was something like gitdir = 'path to the deleted worktree [D:/path/path/path/.git/worktrees/horus_app_v100] . With this file inside, Git didn't even recognized the child folder as part of the Git repository. So I deleted this file (.git) and everything seems to work now.

Solution 2:[2]

My basic understanding is that git status checks for a folder called '.git'. This is where all the git configuration and version control is stored. Therefore, if there is no '.git' folder then the git command won't have the necessary information see that this is a git repository.

My guess is that '.git' folder got deleted with the horus_app_v100 deletion.

My advice would be, if you have not made any changes, just delete the project and clone it again.

If you have made changes, clone it again and do a comparison between the two projects.

(There must be a better way, but let the Git Gurus help us both out with that)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Projetinho
Solution 2