I have GIT_WORK_TREE
set to .
and GIT_DIR
set to .git
. When I run git init --bare
, I get the following error:
fatal:
GIT_WORK_TREE
(or--work-tree=<directory>
) not allowed without specifyingGIT_DIR
(or--git-dir=<directory>
)
What's up with that? I suspect that it might have something to do with GIT_DIR
being set to .
(maybe it considers GIT_DIR
unset if it points to the current working directory?). Regardless, it would be great to have this behave properly so I don't have to unset GIT_WORK_TREE every time I want to initialize a Git repo.
This error message comes from
builtin/init-db.c
So on Unbuntu, unset
GIT_WORK_TREE
just before doing agit init --bare
.See "Unset an environmental variable for a single command":
git init --bare
is not "adding remote", so you need to check what command triggers that error message.On Windows, use
cmd /V/ /C
as explained here: