在PHP中git post-receive hook

时间:2012-01-24 01:51:10

标签: php git githooks

我希望能够在post-receive hook上执行php挂钩,将文件从git repo复制到同一服务器上的web文件夹,只有在推送时才会运行,而忽略其他分支。以下是我到目前为止所做的事情。

!/usr/bin/php
<?php

exec("git archive master | tar -x -C /var/www/", $output);

?>

基本上,我不知道如何使用php访问git参数。

1 个答案:

答案 0 :(得分:0)

不要忘记收件后挂钩 doesn't take arguments :它会读取stdin上的数据。

  

“receive-receive”脚本在receive-pack接受包并且存储库已更新后运行。它通过stdin传递参数:

<oldrev> <newrev> <refname>

所以你需要阅读extract the branch的所谓参数(例子是bash,但你可以调整它)

相关问题