tags:

views:

48

answers:

2

ON A SERVER

  • I created a git repo in the working directory of my web-app /html.

  • To create a git 'host' repo, I ran git clone --bare html html.git.

  • I now have a git 'host' repo and a git 'client' repo on the remote server at /html.git (host) & /html (client).

I want to push from my local machine to the server and not have to do a git pull ON THE SERVER.

ON MY LOCAL MACHINE

When I push from my local machine to the remote 'host' repo, I want to use the post-receive hook to run a git pull on the remote 'client' repo.

Is this possible or is this the easiest way of doing this?

Going to be trying to use this method: http://toroid.org/ams/git-website-howto

+3  A: 

It should be possible. The git hooks are just ordinary scripts that are given some useful arguments, so (assuming the git user has access to both repos) you should be able to do something like:

cd /path/to/client/repo && git pull host master
Cameron Skinner
This worked - A good walkthrough here: http://joemaller.com/990/a-web-focused-git-workflow/
adamyonk
A: 

Instead of running git pull in the remote 'client' repo, you can directly push from the 'host' repo into the client.

In /path/to/host/repo/.git/hooks/post-receive, just have something like :

#!/bin/bash
git push ../html master
Matthieu
I didn't know it was possible to push to a 'client' repo like that.. I think I should be able to push from my local computer TO the client repo on the server.
adamyonk
Sure you can... as long as you have the right permissions.
Matthieu