Trying to create a git repo that does an automatic checkout everytime someone updates origin

Posted by Dane Larsen on Server Fault See other posts from Server Fault or by Dane Larsen
Published on 2011-02-06T08:54:00Z Indexed on 2011/02/06 23:28 UTC
Read the original article Hit count: 304

Filed under:
|

Basically, I have a server with a git repo 'origin'. I'm trying to have another repo auto-pull from origin every time someone pushes code to it. I've been using the hooks in origin, specifically post-receive. So far, my post receive looks something like this:

#!/bin/sh
GIT_DIR=/home/<user>/<test_repo>
git pull origin master

But when I push to origin from another computer, I get the error:

remote: fatal: Not a git repository: '/home/<user>/<test_repo>'

However, test_repo most definitely is a git repo. I can cd into it and run 'git pull origin master' and it works fine.

Is there an easier way to do what I'm trying to do? If not, what am I doing wrong with this approach? Thanks in advance.

Edit, to clarify: The repo is a website in progress, and I'd like to have a version of it available at all times that is fully up to date.

© Server Fault or respective owner

Related posts about git

Related posts about git-repository