Table of Contents

svn To git Transition

This was done against trunk/rosegarden, so the history begins at 2006-02-24 r7161 [3398d014].


  • Decide how to prevent accidental pushing to the old svn repo
    • I've removed developer write privileges. So long as admins are careful, this shouldn't be an issue.
    • A pre-commit hook that returns 1 (exit 1) should prevent any and all commits. Problem is that we still use svn for the website and for backing up the wiki. So we'll need to be a little less heavy handed.
  • Mirror new repo on github

Resources script to get a full copy of the rg svn repo to your local drive. This speeds up the conversion massively.

# -a is equivalent to -rlptgoD
# We don't want group or owner.
# -r - Recursive
# -l - Symlinks as symlinks
# -p - Permissions
# -t - Times
# -g - Group (we don't want this)
# -o - Owner (we don't want this)
# -D - Devices and Specials
rsync -rlptDv .

rg-svn-authors script to extract all authors from the local copy of the svn repo.

cd /tmp
# Checkout a temporary copy from my copy of the server.
svn co file:///home/ted/devel/rosegarden-svn-backup/code/trunk rg-trunk
cd rg-trunk
# Extract authors from the log.
svn log -q | \
  awk -F '|' '/^r/ {sub("^ ", "", $2); sub(" $", "", $2); print $2" = "$2" <"$2">"}' \
  | sort -u > ../authors.txt

Authors.txt needed for git-svn to convert. It must be complete.

alteholz = Thorsten Alteholz <>
alvarudras = alvar udras <>
bownie = Richard Bown <>
cannam = Chris Cannam <>
cjnfryer = Chris Fryer <>
dfaure_kde = David Faure <>
didierburli = didierburli <>
dmmcintyr = D. Michael McIntyre <>
emrum = Emanuel Rumpf <>
glaurent = Guillaume Laurent <>
gperciva = Graham Percival <>
gzoumix = Michaël Lienhardt <>
hannibal203 = hannibal203 <>
hansk = Hans Kieserman <>
hean01 = Henrik Andersson <>
hjunes = Heikki Junes <>
iangardner = Ian Gardner <>
ilan1 = Ilan Tal <>
janifr = Jani Frilander <>
jkyro = Jaakko H Kyro <>
marcospcmusica = Marcos Guglielmetti <>
markhymers = Mark Hymers <>
msjulie = Julie S. <>
(no author) = (no author) <(no author)>
nvdberg = Niek van den Berg <>
phisto_3h = Phil Mac <>
pjhacnau = Peter Howard <>
plcl = Pedro Lopez-Cabanillas <>
prokoudine = Alexandre Prokoudine <>
raboofje = Arnout Engelen <>
root = root <root>
tedfelix = Ted Felix <>
tehom = Tom Breton <>
titola = Tito Latini <>
uid21183 = uid21183 <uid21183>
uid26034 = uid26034 <uid26034>
vacuum-for-time = Shelagh Manton <>
williamrg = William <>
yguillemot = Yves Guillemot <>

rg-git2svn script

readonly authors=/tmp/authors.txt
readonly srcdir=/home/ted/devel/rosegarden-svn-backup/code
readonly destdir=/tmp/rg-conversion
mkdir "$destdir"
cd "$destdir"
echo Performing an svn clone.  This will take about two hours...
# These git svn clone options cause an inordinate amount of extra work.
# Like days worth.  Seriously.  It gets the commit history starting from
# r1 for *every branch and tag*.  It is unreal.
# I can recreate the important tags in less than an hour.  Using gitk!
#              --tags tags \
#              --branches branches \
# Even without those there were some changes that require rescanning from
# the beginning, but it's not all that bad.
# git svn clone file:///home/ted/devel/rosegarden-svn-backup/code --trunk trunk/rosegarden -A /tmp/authors.txt rosegarden-git-tmp2
time git svn clone "file://$srcdir" \
              --trunk trunk/rosegarden \
              -A "$authors" rosegarden-git-tmp
# This compresses down to about 193M.
# Next we need to convert to a bare git repo.
# I assume this is because we don't want svn connected anymore.
echo Pushing to bare repo.  This will take a moment...
# Create a new bare git repo.
mkdir "$destdir/rosegarden.git"
cd "$destdir/rosegarden.git"
git init --bare .
# Create a "trunk" branch?
git symbolic-ref HEAD refs/heads/trunk
# Get ready to push from $destdir/rosegarden-git-tmp
cd "$destdir/rosegarden-git-tmp"
git remote add bare "$destdir/rosegarden.git"
# Make git-push push all remotes and heads.
git config remote.bare.push 'refs/remotes/*:refs/heads/*'
# Push all the commits from $destdir/rosegarden-git-tmp
# to $destdir/rosegarden.git.
git push bare
# Now the bare repo should have all of the commits.
cd "$destdir/rosegarden.git/"
# For each "origin/xxx" branch, rename to xxx
git for-each-ref --format='%(refname)' refs/heads/origin | cut -d / -f 4 | while read ref; \
     # Create a simpler branch name.  Remove "origin" from the name.
     git branch "$ref" "refs/heads/origin/$ref"
     # Delete the original
     git branch -D "origin/$ref"
# Rename trunk to the more git familiar master.
git branch -m trunk master
# No sense wasting space.  It's about 142Meg when finished.
git gc --aggressive
# The rest of this is just pushing to the destination repo.
#git remote add origin ssh://
#git config branch.master.remote origin
#git config branch.master.merge refs/heads/master
#git push --tags origin master


git-svn generated these branches while it was resolving merges from svn. I'm going to delete them since I have no use for them. Keeping them here in case anyone is interested in them.

* master      65121a34d fix bug with BasicCommand bruteForceRedo
  trunk@10148 745d37839 * commit some random exploratory work to clear it out before the trunk swap I   forgot to do an hour ago on schedule.  Oops.
  trunk@10149 49ac87286 * trunk swap step 3: move branches/qt4 to trunk/
  trunk@10151 90cc5fce4 * blast!  that didn't work as expected: trunk/qt4 moves to foo/ now
  trunk@10152 7a98ef76c * foo/ moves to trunk/
  trunk@10154 c80adcbca * on second thought, move trunk/ to dingle/
  trunk@7559  2bc47cfd7 * Pull PortIterator typedef into AudioPlugin
  trunk@7666  6bc2cad35 (from trunk): Fix bug #1570181 "Changing key to minor is not possible" by i18n "Minor" in all necessary places.
  trunk@7666- 9d4257e28 (from trunk): Fix bug #1570181 "Changing key to minor is not possible" by i18n "Minor" in all necessary places.
  trunk@7953  165e6fc86 since I merged the trunk in the branch rather than the opposite, mv the trunk to a backup branch and then rename the branch to be the trunk *sigh*.
  trunk@9069  e874b1025 * Merge from trunk
dev/svn_to_git_transition.txt · Last modified: 2022/05/06 16:07 (external edit)
Recent changes RSS feed Creative Commons License Valid XHTML 1.0 Valid CSS Driven by DokuWiki