Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Script to sync WordPress SVN to GitHub
# cd into the directory
cd ~/gitsync/github-wordpress-sync/;
# Make sure we are not already running
if [ -f .sync-running ];then
if test ! `find ".sync-running" -mmin +10`;then
# Currently running, but not stuck
exit 1;
# Mark as running
touch .sync-running
# Switch to the master branch (which syncs to trunk)
git checkout master;
# Slurp down svn changes
git svn fetch;
# Rebase the changes from trunk into master
git svn rebase;
# Cycle through svn tags and create a git tag for each
git for-each-ref refs/remotes/tags | cut -d / -f 4- | while read ref; do git tag $ref refs/remotes/tags/$ref > /dev/null 2>&1; done;
# Cycle through svn branches and create a git branch for each
# Skip any branches that don't have changes to speed this up
svn list | grep -oE '[3-9]\.[0-9]' | while read branch; do git branch -f $branch-branch remotes/$branch > /dev/null 2>&1; done;
# Back to master
# git checkout master;
# Push branches and tags to GitHub (markjaquith/WordPress)
git push --all github;
git push --tags github;
# Push branches and tags to GitHub (WordPress/WordPress)
git push --all wordpress;
git push --tags wordpress;
# Mark as not running
rm .sync-running
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.