{"thread":{"id":"10158","subject":"Post-update hook problems","startedAt":"2007-10-05T11:27:22Z","lastAt":"2007-10-05T12:27:17Z","messageCount":3,"participants":["Geoffrey Ferrari","Frank Lichtenheld","Mike Ralphson"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"54938","messageId":"930d91430710050427o79395023nffe3bd842a87cddb@mail.gmail.com","threadId":"10158","inReplyTo":null,"subject":"Post-update hook problems","fromName":"Geoffrey Ferrari","fromEmail":"geoffrey.ferrari@googlemail.com","sentAt":"2007-10-05T11:27:22Z","receivedAt":"2007-10-05T11:27:22Z","isPatch":false,"sender":{"key":"geoffrey.ferrari@googlemail.com","avatar":null},"body":"I have a public and a private git repository on the same machine, in\nthe same user's home directory. I want to ensure that when the public\nrepos is updated, the private repos automatically receives those\nupdates. Let's just assume that this is a good idea.\n\nSo, I've created a post-update hook script and made it executable. The\nscript is very simple. It 'cd's to the private repos and then does a\ngit pull. It looks, in essence, like this:\n\n--\n#!/bin/sh\n\ncd /user/home/private/repos\ngit pull\n\nexit 0\n--\n\nWhen I run this script directly, it works fine. (It also works fine\nwhen I run it directly over ssh). However, when I do a git push to the\npublic repos, (either locally or remotely over ssh) the script is\ncalled but reports back the following error:\n\n--\nfatal: Not a git repository: '.'\nFailed to find a valid git directory.\n--\n\nCan anyone explain why this happens? And how can I make the script\nwork properly?\n\nWith sincere thanks for your help,\n\nGeoffrey Ferrari\n"},{"id":"54940","messageId":"20071005120850.GM31659@planck.djpig.de","threadId":"10158","inReplyTo":"930d91430710050427o79395023nffe3bd842a87cddb@mail.gmail.com","subject":"Re: Post-update hook problems","fromName":"Frank Lichtenheld","fromEmail":"frank@lichtenheld.de","sentAt":"2007-10-05T12:08:50Z","receivedAt":"2007-10-05T12:08:50Z","isPatch":false,"sender":{"key":"frank@lichtenheld.de","avatar":"https://gravatar.com/avatar/b9f1d4b120e138f157c9e480d0818197c474628923786adb98f30017cdb99c3c?d=mp&s=160"},"body":"On Fri, Oct 05, 2007 at 12:27:22PM +0100, Geoffrey Ferrari wrote:\n> --\n> fatal: Not a git repository: '.'\n> Failed to find a valid git directory.\n> --\n> \n> Can anyone explain why this happens? And how can I make the script\n> work properly?\n\nI'm no hook expert, but it may have something to do with some\nenvironment variables that are set in hooks, you might need to change\nvariables like GIT_DIR.\n\nGruesse,\n-- \nFrank Lichtenheld <frank@lichtenheld.de>\nwww: http://www.djpig.de/\n"},{"id":"54945","messageId":"e2b179460710050527w185fd4b1kfbe278cf7055de4c@mail.gmail.com","threadId":"10158","inReplyTo":"20071005120850.GM31659@planck.djpig.de","subject":"Re: Post-update hook problems","fromName":"Mike Ralphson","fromEmail":"mike.ralphson@gmail.com","sentAt":"2007-10-05T12:27:17Z","receivedAt":"2007-10-05T12:27:17Z","isPatch":false,"sender":{"key":"mike.ralphson@gmail.com","avatar":"https://avatars.githubusercontent.com/u/21603?v=4"},"body":"On 10/5/07, Frank Lichtenheld <frank@lichtenheld.de> wrote:\n> On Fri, Oct 05, 2007 at 12:27:22PM +0100, Geoffrey Ferrari wrote:\n> > --\n> > fatal: Not a git repository: '.'\n> > Failed to find a valid git directory.\n> > --\n> >\n> > Can anyone explain why this happens? And how can I make the script\n> > work properly?\n>\n> I'm no hook expert, but it may have something to do with some\n> environment variables that are set in hooks, you might need to change\n> variables like GIT_DIR.\n\nAck.\n\nThe hooks seem to assume repositories pushed into are bare, so the\nGIT_DIR isn't set to a .git subdirectory (even if it exists).\n\nMike\n"}]}