开发者

Publish git repository to remote http server

开发者 https://www.devze.com 2023-01-02 07:33 出处:网络
I work on a git repository where we build an php community but i need to show it somewher开发者_如何学Goe so I am looking for a way to automatic upload my files to a remote http server when i push to

I work on a git repository where we build an php community but i need to show it somewher开发者_如何学Goe so I am looking for a way to automatic upload my files to a remote http server when i push to the repository.

Thanks /Victor


Like Subversion Git offers a hook mechanism, too. Check out the githooks man page. Basically you just need to write a checkout and deploy script for your PHP application as a post-commit hook.

For github you should have a look at their webhooks mechanism.


If there is no separate git repo on the second server, I would export files from archive:

git checkout-index -a -f --prefix=/target/path/

And then used sftp to synchronize with remote server:

#!/bin/bash
HOST="ftp.example.com"
USER="user"
PASS="pass"
LCD="/var/www/yourdir"
RCD="/www/"
lftp -c "
#debug;
open ftp://$USER:$PASS@$HOST;
lcd $LCD;
cd $RCD;
mirror --only-newer \
       --reverse \
       --verbose \
       --exclude-glob somepattern ";

You may automate this process as a build script (e.g. Phing), our bind as a post commit git hook, like it has been mentioned before.

0

精彩评论

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