开发者

Update git remote repo on push

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 loc开发者_高级运维al 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


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


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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜