# git pull and GIT_DIR

3 messages from 2012-05-02 to 2012-05-02. Participants: bill lam, Junio C Hamano.
Thread: https://gitlist.dev/t/30396

## bill lam, 2012-05-02 14:25

Subject: git pull and GIT_DIR
Message-ID: <20120502142536.GA2609@debian.b2j>
URL: https://gitlist.dev/e/20120502142536.GA2609%40debian.b2j

```
It appeared that

a)
cd /path/to && git pull git/https://....

will fetch and checkout latest changes to working tree.  This is as
expected.  On the contrary

b)
GIT_DIR=/path/to/.git git pull git/https://....

will only update git repo, but leaving working tree untouched.
Subsequent git status and git diff will indicate unstaged changes, 
apparently a commit that will revert the updated git repo. I have to
do 'git reset --hard' to really update the working three.

I'm not sure if this is an intended behavior or I missed something. 

-- 
regards,
====================================================
GPG key 1024D/4434BAB3 2008-08-24
gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3

```

## Junio C Hamano, 2012-05-02 19:11

Subject: Re: git pull and GIT_DIR
Message-ID: <7v62ceiejp.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7v62ceiejp.fsf%40alter.siamese.dyndns.org
In-Reply-To: <20120502142536.GA2609@debian.b2j>

```
bill lam <cbill.lam@gmail.com> writes:

> It appeared that
>
> a)
> cd /path/to && git pull git/https://....
>
> will fetch and checkout latest changes to working tree.  This is as
> expected.  On the contrary
>
> b)
> GIT_DIR=/path/to/.git git pull git/https://....
>
> will ...

-ETOOLITTLEINFO.

When you do b)

 - is /path/to the working tree for /path/to/.git?

 - where is your $(pwd)?

 - if your $(pwd) is different from /path/to, how are you telling git
   where the working tree is?  are you using GIT_WORK_TREE or something?

```

## bill lam, 2012-05-02 23:21

Subject: Re: git pull and GIT_DIR
Message-ID: <20120502232102.GB2609@debian.b2j>
URL: https://gitlist.dev/e/20120502232102.GB2609%40debian.b2j
In-Reply-To: <7v62ceiejp.fsf@alter.siamese.dyndns.org>

```
It is non-bare and /path/to is the working tree.  The git pull was
run inside a shell and $(pwd) is $HOME.  GIT_WORK_TREE is not used.
This let me remember that there were some directories/files checkout
under $HOME that should be under /path/to.  I might recall
incorrectly, but does it mean that it need to use the form

GIT_DIR=/path/to/.git GIT_WORK_TREE=/path/to git pull url

to make it to the samething as

cd /path/to && git pull url

-- 
regards,
====================================================
GPG key 1024D/4434BAB3 2008-08-24
gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3

```
