Skip to content

Instantly share code, notes, and snippets.

@dogmatic69
Last active September 28, 2015 10:09
Show Gist options
  • Select an option

  • Save dogmatic69/1422991 to your computer and use it in GitHub Desktop.

Select an option

Save dogmatic69/1422991 to your computer and use it in GitHub Desktop.
After running git svn clone, handy little script that will create all the correct branches and tags for the repo
#!/usr/bin/php5
<?php
$branches = array_filter(explode("\n", `git branch -r`));
`clear`;
foreach((array)$branches as $branch) {
echo sprintf("Working on %s\n======================================\n\n", $branch);
$commands = array();
$branch = trim($branch);
if(empty($branch)) {
continue;
}
$tagName = str_replace('tags/', '', $branch);
$branchLocal = $branch . '-svn';
$commands[] = "git checkout -b $branchLocal remotes/$branch";
if(strstr($branch, 'tags/')) {
echo sprintf("Creating tag '%s' from branch 'remotes/%s'\n", $tagName, $branch);
$commands[] = "git tag $tagName";
$commands[] = "git checkout master";
$commands[] = "git branch -D $branchLocal";
} else {
$commands[] = "git checkout master";
}
foreach($commands as $command) {
echo sprintf("Running command: '%s'\n", $command);
`$command`;
}
echo "\n\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment