threads / discuss / 10158

Post-update hook problems

Subject: Post-update hook problems

## tl;dr

3 messages between Oct 5, 2007 and Oct 5, 2007.

replies: 2people: 3as markdown or json

Geoffrey Ferrari· Oct 5, 2007, 11:27 UTC · lore

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· Oct 5, 2007, 12:08 UTC · re: Geoffrey Ferrari · lore

Re: Post-update hook problems

On Fri, Oct 05, 2007 at 12:27:22PM +0100, Geoffrey Ferrari wrote:
Show 7 quoted lines
> --
> 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· Oct 5, 2007, 12:27 UTC · re: Frank Lichtenheld · lore

Re: Post-update hook problems

On 10/5/07, Frank Lichtenheld <frank@lichtenheld.de> wrote:
Show 12 quoted lines
> 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

← back to recent threads