git-export
#!/usr/bin/php -q
<?php
if ($argc < 3) { // too few arguments
echo "git export /path/to/repo /destination/dir [branch]\n";
return;
}
$git_dir = rtrim($argv[1], '/') .'/.git';
if (!file_exists($git_dir)) { // bare repo?
$git_dir = $argv[1];
}
$work_tree = $argv[2];
if (!file_exists($work_tree)) {
mkdir($work_tree);
}
$branch = isset($argv[3]) ? $argv[3] : 'master';
passthru("git --git-dir=$git_dir --work-tree=$work_tree checkout -f -q $branch");
Based on http://stackoverflow.com/a/22702614/3135284