Reputation: 1360
When I type git status
in any folder it lists the status of one of my git projects, compared to the current folder. Even when I am in another git project. Also, if I cd
to /root
folder and check there is no .git
folder present and type in git status
I will see the status of that folder against my git project.
Is there some default mapping in git, global config looks ok?
Upvotes: 0
Views: 168
Reputation: 13377
When you have GIT_DIR
set in the environment, but not also GIT_WORK_TREE
, then you are operating Git outside its specifications.
Either:
Remove GIT_DIR
from the environment and let Git discover the .git
directory itself,
Or set GIT_WORK_TREE
as well to point to the worktree corresponding to the GIT_DIR
.
But, frankly, the latter is really not how one wants to operate Git during regular work. You should do the former.
Upvotes: 2
Reputation: 45659
Well... it's in the comments, but for visibility:
This happens if you have a GIT_DIR
environment variable pointing to a particular repository. GIT_DIR
overrides the normal directory-search rules for finding the .git
folder and simply says "you're in a repo and the metadata is here".
Generally I would clear the GET_DIR
variable, and only set it when needed. I'm not sure what purpose you have it set for, and to the extent that purpose is still a thing, you may have to do some other stuff first to make sure it's set when it should be. But I can say the only times I've ever used GET_DIR
are in scripts (and then I make sure to clear it when the script's work is done) and I can't think of why you'd want it set all the time - for the reason you've just experienced.
Upvotes: 1