{{tag>git shell scm}}

====== Скрипт автоматической загрузки c github ======

  * git clone http:
  * git pull
  * git push
  * git checkout new_branch -f

===== Github =====

<code>
Скрипт автоматической загрузки с github.ru
Настроить тут: https://github.com/[Project-name]/admin/hooks
Перейти в "WebHook URLs" и добавить Url с параметрами
</code>

  http://8.8.8.8/git_pull.php?site=site.ru&branch=new_branch

<code php>
<?php
echo "Git pull<br>";
$Branch = isset($_GET['branch'])? $_GET['branch']: "Body";
$site_name = $_GET['site'];
$path_to_dir = '/var/www/nginx-sites/'.$site_name.'/github';

$cmd = "cd $path_to_dir && ";
$cmd .= "git reset --hard HEAD && ";
$cmd .= "git pull && ";
$cmd .= "git checkout $Branch -f ";

echo "$cmd<br>";

echo shell_exec ( $cmd );
</code>

==== Pull request ====

  * http://habrahabr.ru/post/125999/



