# $GIT_DIR usage

6 messages from 2007-08-05 to 2007-08-05. Participants: Dan Zwell, Johannes Schindelin, Dmitry Kakurin.
Thread: https://gitlist.dev/t/9392

## Dan Zwell, 2007-08-05 09:58

Subject: $GIT_DIR usage
Message-ID: <46B59F63.8020707@gmail.com>
URL: https://gitlist.dev/e/46B59F63.8020707%40gmail.com

```
Hi, I had a question about $GIT_DIR. That is to say, it doesn't seem to 
work. I am using Git 1.5.2.4. See the following: (all the commands I 
tried besides "git-init" failed).

$ export GIT_DIR="`pwd`/.git_public"
$ git init
warning: templates not found /usr/share//git-core/templates/
Initialized empty Git repository in /home/user/temp/.git_public/
$ echo > new_file
$ git add new_file
fatal: add must be run in a work tree
$ git commit -a
fatal: /usr/bin/git-commit cannot be used without a working tree.
$ git commit
fatal: /usr/bin/git-commit cannot be used without a working tree.
$

Is $GIT_DIR not meant to be used this way? Does it have a different 
purpose / use case, or is this just a bug?

Thanks,
Dan

```

## Dmitry Kakurin, 2007-08-05 11:55

Subject: Re: $GIT_DIR usage
Message-ID: <678E8953ECEB4B72A99DEA2137B05823@ntdev.corp.microsoft.com>
URL: https://gitlist.dev/e/678E8953ECEB4B72A99DEA2137B05823%40ntdev.corp.microsoft.com
In-Reply-To: <46B59F63.8020707@gmail.com>

```
I think you also need to set GIT_WORK_TREE.
This way Git will know the root of directories that it controls.

- Dmitry
----- Original Message ----- 
From: "Dan Zwell" <dzwell@gmail.com>
Newsgroups: gmane.comp.version-control.git
To: <git@vger.kernel.org>
Sent: Sunday, 5 August 2007 2:58
Subject: $GIT_DIR usage


> Hi, I had a question about $GIT_DIR. That is to say, it doesn't seem to 
> work. I am using Git 1.5.2.4. See the following: (all the commands I 
> tried besides "git-init" failed).
> 
> $ export GIT_DIR="`pwd`/.git_public"
> $ git init
> warning: templates not found /usr/share//git-core/templates/
> Initialized empty Git repository in /home/user/temp/.git_public/
> $ echo > new_file
> $ git add new_file
> fatal: add must be run in a work tree
> $ git commit -a
> fatal: /usr/bin/git-commit cannot be used without a working tree.
> $ git commit
> fatal: /usr/bin/git-commit cannot be used without a working tree.
> $
> 
> Is $GIT_DIR not meant to be used this way? Does it have a different 
> purpose / use case, or is this just a bug?
> 
> Thanks,

```

## Dan Zwell, 2007-08-05 12:22

Subject: Re: $GIT_DIR usage
Message-ID: <46B5C11E.4000101@gmail.com>
URL: https://gitlist.dev/e/46B5C11E.4000101%40gmail.com
In-Reply-To: <678E8953ECEB4B72A99DEA2137B05823@ntdev.corp.microsoft.com>

```
Dmitry Kakurin wrote:
> I think you also need to set GIT_WORK_TREE.
> This way Git will know the root of directories that it controls.
> 
> - Dmitry
> ----- Original Message ----- From: "Dan Zwell" <dzwell@gmail.com>
> Newsgroups: gmane.comp.version-control.git
> To: <git@vger.kernel.org>
> Sent: Sunday, 5 August 2007 2:58
> Subject: $GIT_DIR usage
> 
> 
>> Hi, I had a question about $GIT_DIR. That is to say, it doesn't seem 
>> to work. I am using Git 1.5.2.4. See the following: (all the commands 
>> I tried besides "git-init" failed).
>>
>> $ export GIT_DIR="`pwd`/.git_public"
>> $ git init
>> warning: templates not found /usr/share//git-core/templates/
>> Initialized empty Git repository in /home/user/temp/.git_public/
>> $ echo > new_file
>> $ git add new_file
>> fatal: add must be run in a work tree
>> $ git commit -a
>> fatal: /usr/bin/git-commit cannot be used without a working tree.
>> $ git commit
>> fatal: /usr/bin/git-commit cannot be used without a working tree.
>> $
>>
>> Is $GIT_DIR not meant to be used this way? Does it have a different 
>> purpose / use case, or is this just a bug?
>>
>> Thanks,
>> Dan
> 

Thank you. I also had to upgrade Git to the as-yet unreleased version 
(this variable doesn't exist in the current stable release), but what 
you said makes sense and seems like it should work.

Dan

```

## Johannes Schindelin, 2007-08-05 12:33

Subject: Re: $GIT_DIR usage
Message-ID: <Pine.LNX.4.64.0708051332230.14781@racer.site>
URL: https://gitlist.dev/e/Pine.LNX.4.64.0708051332230.14781%40racer.site
In-Reply-To: <46B59F63.8020707@gmail.com>

```
Hi,

On Sun, 5 Aug 2007, Dan Zwell wrote:

> $ export GIT_DIR="`pwd`/.git_public"
> $ git init
> warning: templates not found /usr/share//git-core/templates/
> Initialized empty Git repository in /home/user/temp/.git_public/

I think that you implicitly created a bare repository with that.  Just 
check if "git config core.bare" returns true.

If so, you need to change that in order to have a working tree.

Hth,
Dscho

```

## Dan Zwell, 2007-08-05 13:02

Subject: Re: $GIT_DIR usage
Message-ID: <46B5CA50.3050500@gmail.com>
URL: https://gitlist.dev/e/46B5CA50.3050500%40gmail.com
In-Reply-To: <Pine.LNX.4.64.0708051332230.14781@racer.site>

```
Johannes Schindelin wrote:
> Hi,
> 
> On Sun, 5 Aug 2007, Dan Zwell wrote:
> 
>> $ export GIT_DIR="`pwd`/.git_public"
>> $ git init
>> warning: templates not found /usr/share//git-core/templates/
>> Initialized empty Git repository in /home/user/temp/.git_public/
> 
> I think that you implicitly created a bare repository with that.  Just 
> check if "git config core.bare" returns true.
> 
> If so, you need to change that in order to have a working tree.
> 
> Hth,
> Dscho
> 
> 

You are exactly right, I accidentally created a bare repository. I can 
do 2 things: I can change core.bare to true, or I can create .git in the 
normal way, then move rename it. Both things still have the problem of 
git not knowing where the working directory is. Is the only way to fix 
this in 1.5.2.4, or is my only option to upgrade?

Thanks,
Dan

```

## Johannes Schindelin, 2007-08-05 13:41

Subject: Re: $GIT_DIR usage
Message-ID: <Pine.LNX.4.64.0708051440460.14781@racer.site>
URL: https://gitlist.dev/e/Pine.LNX.4.64.0708051440460.14781%40racer.site
In-Reply-To: <46B5CA50.3050500@gmail.com>

```
Hi,

On Sun, 5 Aug 2007, Dan Zwell wrote:

> I can do 2 things: I can change core.bare to true, or I can create .git 
> in the normal way, then move rename it. Both things still have the 
> problem of git not knowing where the working directory is. Is the only 
> way to fix this in 1.5.2.4, or is my only option to upgrade?

I really have to ask now: why is ./.git/ not an appropriate name?

Ciao,
Dscho

```
