{"thread":{"id":"13730","subject":"post-receive hook","startedAt":"2008-05-30T08:10:49Z","lastAt":"2008-05-30T09:43:04Z","messageCount":3,"participants":["david@lang.hm","Johan Herland"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"78116","messageId":"alpine.DEB.1.10.0805300108140.4014@asgard.lang.hm","threadId":"13730","inReplyTo":null,"subject":"post-receive hook","fromName":"","fromEmail":"david@lang.hm","sentAt":"2008-05-30T08:10:49Z","receivedAt":"2008-05-30T08:10:49Z","isPatch":false,"sender":{"key":"david@lang.hm","avatar":null},"body":"I'm trying to setup a post-receive hook to do a checkout -f when I push to \na public repo (it's a web based tool and I want the executables to be \nupdated with a push)\n\nunfortunantly if I just add git checkout -f to the post-receive hooks it \nchecks the files out in the .git directory.\n\nif I do a cd .. ; git checkout -f I get an error message complaining that \nit's not in a git repository, but if I manually cd to that directory and \ndo a checkout it works.\n\nwhat am I missing here?\n\nDavid Lang\n"},{"id":"78120","messageId":"200805301106.33992.johan@herland.net","threadId":"13730","inReplyTo":"alpine.DEB.1.10.0805300108140.4014@asgard.lang.hm","subject":"Re: post-receive hook","fromName":"Johan Herland","fromEmail":"johan@herland.net","sentAt":"2008-05-30T09:06:33Z","receivedAt":"2008-05-30T09:06:33Z","isPatch":false,"sender":{"key":"johan@herland.net","avatar":"https://avatars.githubusercontent.com/u/547031?v=4"},"body":"On Friday 30 May 2008, david@lang.hm wrote:\n> I'm trying to setup a post-receive hook to do a checkout -f when I push to \n> a public repo (it's a web based tool and I want the executables to be \n> updated with a push)\n> \n> unfortunantly if I just add git checkout -f to the post-receive hooks it \n> checks the files out in the .git directory.\n> \n> if I do a cd .. ; git checkout -f I get an error message complaining that \n> it's not in a git repository, but if I manually cd to that directory and \n> do a checkout it works.\n> \n> what am I missing here?\n\nI'm guessing that the post-receive hook is invoked with \"GIT_DIR=.\", which goes bad the moment you chdir anywhere. I have this in my own update hook script:\n\nif [ \"$GIT_DIR\" = \".\" ]; then\n\tGIT_DIR=`pwd`\nfi\n\nIf you do this before the \"cd .. ; git checkout -f\", you might have better luck.\n\n\nHave fun! :)\n\n...Johan\n\n-- \nJohan Herland, <johan@herland.net>\nwww.herland.net\n"},{"id":"78122","messageId":"alpine.DEB.1.10.0805300242460.4014@asgard.lang.hm","threadId":"13730","inReplyTo":"200805301106.33992.johan@herland.net","subject":"Re: post-receive hook","fromName":"","fromEmail":"david@lang.hm","sentAt":"2008-05-30T09:43:04Z","receivedAt":"2008-05-30T09:43:04Z","isPatch":false,"sender":{"key":"david@lang.hm","avatar":null},"body":"On Fri, 30 May 2008, Johan Herland wrote:\n\n> On Friday 30 May 2008, david@lang.hm wrote:\n>> I'm trying to setup a post-receive hook to do a checkout -f when I push to\n>> a public repo (it's a web based tool and I want the executables to be\n>> updated with a push)\n>>\n>> unfortunantly if I just add git checkout -f to the post-receive hooks it\n>> checks the files out in the .git directory.\n>>\n>> if I do a cd .. ; git checkout -f I get an error message complaining that\n>> it's not in a git repository, but if I manually cd to that directory and\n>> do a checkout it works.\n>>\n>> what am I missing here?\n>\n> I'm guessing that the post-receive hook is invoked with \"GIT_DIR=.\", which goes bad the moment you chdir anywhere. I have this in my own update hook script:\n>\n> if [ \"$GIT_DIR\" = \".\" ]; then\n> \tGIT_DIR=`pwd`\n> fi\n>\n> If you do this before the \"cd .. ; git checkout -f\", you might have better luck.\n\nthanks, that solved the problem.\n\nDavid Lang\n"}]}