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
Explicitly setting the GIT_DIR
environment variable forces git to use the given directory as the git repository. It is never needed during normal use.
In your example, because have specified a GIT_DIR
and it isn't named .git
(the leading dot is important) and you haven't provided a --work-tree
option or set the GIT_WORK_TREE
environment variable, that you want a bare repository when you said git init
.
Because a bare repository has no working tree a large selection of commands don't make sense with a bare repository. git add
is just one.
Is there a particular reason that you need to use a non-standard location for your git repository, rather than in a .git
subfolder under the working tree root? While it's possible to arrange this it tends to be more work and more liable to user mistakes.