Skip to content
rpetre edited this page Aug 6, 2012 · 7 revisions

Update: Since I found out the wordpress team now maintains their own git repo here on github, I decided to start tracking them for my projects, so I’m discontinuing this. I stopped pushing here and I’ll probably delete it soon. Please don’t use this for anything you care about :)


I’m using a git-svn clone that I update regularly via cron, so I’m pushing it here. Haven’t really figured out how to do it properly (for instance fixing the authors, or nice commit logs, and so on), I’m hoping to catch things along the way.

The repository has been done “by the book” with git-svn clone (although rumour around the ‘Net says that bare git-svn clones are possible). After a while I moved the git-svn branches under refs/remotes/upstream to ease selecting heads (I think adding —prefix=“upstream/” to the git-svn clone call will do the same, but I haven’t tested it. The cron script I use, every half hour, goes like this:

#!/bin/bash
PATH=/usr/bin:/bin
REPO=/srv/git/wordpress-main.git
REMOTE=github
cd $REPO
git svn fetch
git svn rebase -l
# Make the git master branch always track the svn trunk
git update-ref refs/heads/master refs/remotes/upstream/trunk
# Copy all other remote branches (only svn branches, excluding trunk and tags) to normal git branches
git for-each-ref refs/remotes/upstream | cut -d / -f 4- | grep -v -x trunk | grep -v tags | while read ref
do
git update-ref "refs/heads/$ref" "refs/remotes/upstream/$ref"
done
#make a lightweight tag for any unseen svn tags, then delete the tags/tag branches
git for-each-ref refs/remotes/upstream/tags | cut -d / -f 5- | while read ref
do
git show-ref --quiet --verify "refs/tags/$ref" && continue
git tag "$ref" "refs/remotes/upstream/tags/$ref"
git update-ref -d "refs/remotes/upstream/tags/$ref" "refs/remotes/upstream/tags/$ref"
done
# Prune branches or tags that have been removed in svn
git for-each-ref refs/heads | cut -d / -f 3- | grep -v -x master | while read ref
do
git show-ref --quiet --verify "refs/remotes/upstream/$ref" || git update-ref -d "refs/heads/$ref" "refs/heads/$ref"
done
git gc --auto
git push $REMOTE --mirror
Clone this wiki locally