开发者

How (and where) should a hook be defined to autoupload a website to production?

I have a central server acting as a git server, and I push my changes from another pc. I work in parallel with another developer, too. He prepared a hook in the git server so when we pushed it pulls any change.

What we would want to do now is to also pull from a production server. We work with two main branches (master and stable), so when we decide to commit something as stable, we would like the production server to pull it in any way. I'm not plenty sure if it is possible to p开发者_开发技巧ull on demand, but I have found little to no information about this aspect. Do you have any idea? Thanks in advance.


Your question is not exactly clear and requires more details on your setup.

If you want to pull in your production server ( or push to your production server from the central server ), and if you are using a hook like update , post-receive or post-update, you can easily make them pull or push only if you commit to the stable branch.

Taking the specific example of an update hook on the central server, it takes three parameters:

- the name of the ref being updated,
- the old object name stored in the ref,
- and the new objectname to be stored in the ref.

By checking the name of the ref to be what you want( stable ) and then doing a push or pull to the production server will help you achieve the selective update that you want.

http://git-scm.com/docs/githooks


You can't push to the production server because a) by default git won't push to a non-bare repository, and b) if you force it, it can only update the repo, not the working directory. You have to get into the production repository directory and pull from there. You could automate that with a post-receive hook on the central repo, and you should be prepared to deal with file ownership issues.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜