tags:

views:

34

answers:

2

I'm new to git so I apologize (and please correct me) if I misuse terminology here, but I'll do my best.

I'm trying to set up a bare git repo (hub) and a development site working copy (prime) on a web server. I've tried to pattern it after this article. I want the development working copy to be updated whenever the hub repo is pushed to. I'm under the impression that the proper hook for this is post-update, which I have created like so:

#!/bin/sh
whoami
cd /path/to/working-copy/
RET=`git pull`
echo $RET

Update

When I push changes from my local repo to the bare hub I get the following output from the post-update script:

remote: sites
remote: fatal: Not a git repository: '.'

However if I SSH into the server as user 'sites' and execute this script manually it works great Any ideas as to what might be going wrong with this hook or script?

A: 

You probably have a permissions issue. I'm not sure how you have setup your bare git repo, but if it's running under the git user, make sure that git user is allowed to perform the git pull in your project directory.

Optionally try this to find out what user you are when the hook is run:

echo `whoami`
Ariejan
if I ssh into the server as the git user I am able to use git pull in my project directory with no problems. I *believe* that is the user that should be executing the script. I can try adding the whoami line to the script, but where does the output from that script go when it is executed as a hook? Maybe I need to send that output to a log file instead of echoing?
Ty W
What does `echo \`whoami\`` do that `whoami` does not?
Christoffer Hammarström
Output to stdout from a hook script is visible to the remote doing the action. Or, in other words, if you say 'git push', output from a hook on the remote will show up in your stdout.
ebneter
yeah, noticed that as I was playing with stuff. very convenient :)
Ty W