git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: post-receive hook

From
Johan Herland <johan@herland.net>
Date
May 30, 2008, 09:06 UTC
Message-ID
<200805301106.33992.johan@herland.net>
In-Reply-To
<alpine.DEB.1.10.0805300108140.4014@asgard.lang.hm>
On Friday 30 May 2008, david@lang.hm wrote:
Show 12 quoted lines
> I'm trying to setup a post-receive hook to do a checkout -f when I push to 
> a public repo (it's a web based tool and I want the executables to be 
> updated with a push)
> 
> unfortunantly if I just add git checkout -f to the post-receive hooks it 
> checks the files out in the .git directory.
> 
> if I do a cd .. ; git checkout -f I get an error message complaining that 
> it's not in a git repository, but if I manually cd to that directory and 
> do a checkout it works.
> 
> what am I missing here?
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:
if [ "$GIT_DIR" = "." ]; then
	GIT_DIR=`pwd`
fi
If you do this before the "cd .. ; git checkout -f", you might have better luck.
Have fun! :)
...Johan
-- 
Johan Herland, <johan@herland.net>
www.herland.net
Previous: david@lang.hmNext: david@lang.hm
Message 2 of 3 in “post-receive hook”
  1. david@lang.hmMay 30, 2008
  2. Johan HerlandMay 30, 2008
  3. david@lang.hmMay 30, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.