# Post-update hook problems

3 messages from 2007-10-05 to 2007-10-05. Participants: Geoffrey Ferrari, Frank Lichtenheld, Mike Ralphson.
Thread: https://gitlist.dev/t/10158

## Geoffrey Ferrari, 2007-10-05 11:27

Subject: Post-update hook problems
Message-ID: <930d91430710050427o79395023nffe3bd842a87cddb@mail.gmail.com>
URL: https://gitlist.dev/e/930d91430710050427o79395023nffe3bd842a87cddb%40mail.gmail.com

```
I have a public and a private git repository on the same machine, in
the same user's home directory. I want to ensure that when the public
repos is updated, the private repos automatically receives those
updates. Let's just assume that this is a good idea.

So, I've created a post-update hook script and made it executable. The
script is very simple. It 'cd's to the private repos and then does a
git pull. It looks, in essence, like this:

--
#!/bin/sh

cd /user/home/private/repos
git pull

exit 0
--

When I run this script directly, it works fine. (It also works fine
when I run it directly over ssh). However, when I do a git push to the
public repos, (either locally or remotely over ssh) the script is
called but reports back the following error:

--
fatal: Not a git repository: '.'
Failed to find a valid git directory.
--

Can anyone explain why this happens? And how can I make the script
work properly?

With sincere thanks for your help,

Geoffrey Ferrari

```

## Frank Lichtenheld, 2007-10-05 12:08

Subject: Re: Post-update hook problems
Message-ID: <20071005120850.GM31659@planck.djpig.de>
URL: https://gitlist.dev/e/20071005120850.GM31659%40planck.djpig.de
In-Reply-To: <930d91430710050427o79395023nffe3bd842a87cddb@mail.gmail.com>

```
On Fri, Oct 05, 2007 at 12:27:22PM +0100, Geoffrey Ferrari wrote:
> --
> fatal: Not a git repository: '.'
> Failed to find a valid git directory.
> --
> 
> Can anyone explain why this happens? And how can I make the script
> work properly?

I'm no hook expert, but it may have something to do with some
environment variables that are set in hooks, you might need to change
variables like GIT_DIR.

Gruesse,
-- 
Frank Lichtenheld <frank@lichtenheld.de>
www: http://www.djpig.de/

```

## Mike Ralphson, 2007-10-05 12:27

Subject: Re: Post-update hook problems
Message-ID: <e2b179460710050527w185fd4b1kfbe278cf7055de4c@mail.gmail.com>
URL: https://gitlist.dev/e/e2b179460710050527w185fd4b1kfbe278cf7055de4c%40mail.gmail.com
In-Reply-To: <20071005120850.GM31659@planck.djpig.de>

```
On 10/5/07, Frank Lichtenheld <frank@lichtenheld.de> wrote:
> On Fri, Oct 05, 2007 at 12:27:22PM +0100, Geoffrey Ferrari wrote:
> > --
> > fatal: Not a git repository: '.'
> > Failed to find a valid git directory.
> > --
> >
> > Can anyone explain why this happens? And how can I make the script
> > work properly?
>
> I'm no hook expert, but it may have something to do with some
> environment variables that are set in hooks, you might need to change
> variables like GIT_DIR.

Ack.

The hooks seem to assume repositories pushed into are bare, so the
GIT_DIR isn't set to a .git subdirectory (even if it exists).

Mike

```
