Skip to content

Instantly share code, notes, and snippets.

@crowding
Created August 26, 2012 09:05
Show Gist options
  • Save crowding/3476441 to your computer and use it in GitHub Desktop.
Save crowding/3476441 to your computer and use it in GitHub Desktop.
Extract a list of SVN URLs to Git repos
#!/bin/bash -ex
#little script to migrate an SVN URL into a Git repo
#I have already prepared the list of FROM and TO, to be run with
#
#xargs -L 1 < migration.txt ./migration.sh
#
#I have made sure that the repos already exist and are empty, or else
#will be auto-created by Gitolite.
FROM=$1
TO=$2
CWD=`pwd`
trap 'exit 255' ERR
TMP=`tempfile -s .git -d ${HOME}`
trap 'cd "$CWD" && rm -rf "$TMP"' INT TERM EXIT
rm "$TMP"
mkdir "$TMP"
git svn clone "$FROM" "$TMP"
cd "$TMP"
git remote add origin "$TO"
git fetch
git push --all
cd "$CWD"
rm -rf "$TMP"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment