Skip to content

Instantly share code, notes, and snippets.

@Ollo
Created February 28, 2014 07:48
Show Gist options
  • Save Ollo/9266951 to your computer and use it in GitHub Desktop.
Save Ollo/9266951 to your computer and use it in GitHub Desktop.
<?php
// Init vars
$LOCAL_ROOT = "/var/www/my_new_site";
$LOCAL_REPO_NAME = "public_html";
$LOCAL_REPO = "{$LOCAL_ROOT}/{$LOCAL_REPO_NAME}";
$REMOTE_REPO = "[email protected]:jonathanstark/my_new_site.git";
$DESIRED_BRANCH = "dev";
// Delete local repo if it exists
if (file_exists($LOCAL_REPO)) {
shell_exec("rm -rf {$LOCAL_REPO}");
}
// Clone fresh repo from github using desired local repo name and checkout the desired branch
echo shell_exec("cd {$LOCAL_ROOT} && git clone {$REMOTE_REPO} {$LOCAL_REPO_NAME} && cd {$LOCAL_REPO} && git checkout {$BRANCH}");
die("done " . mktime());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment