post-receive hook

3 messages, 2 authors, 2016-06-15 · open the first message on its own page

post-receive hook

From: <hidden>
Date: 2016-06-15 22:44:39

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?

David Lang

Re: post-receive hook

From: Johan Herland <hidden>
Date: 2016-06-15 22:44:39

On Friday 30 May 2008, david@lang.hm wrote:
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, [off-list ref]
www.herland.net

Re: post-receive hook

From: <hidden>
Date: 2016-06-15 22:44:39

On Fri, 30 May 2008, Johan Herland wrote:
On Friday 30 May 2008, david@lang.hm wrote:
quoted
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.
thanks, that solved the problem.

David Lang
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help