Skip to content

Instantly share code, notes, and snippets.

@yancyn
Last active July 20, 2024 00:44
Show Gist options
  • Save yancyn/3f870ca6da4d4a5af5618fbd3ce4dd13 to your computer and use it in GitHub Desktop.
Save yancyn/3f870ca6da4d4a5af5618fbd3ce4dd13 to your computer and use it in GitHub Desktop.
Migrate Archive Google Code SVN to Git

Migrate Archive Google Code SVN to Git

Requirements

  • git
  • git-svn

Setup¹

$ sudo apt-get install git
$ sudo add-apt-repository ppa:git-core/ppa
$ sudo apt-get update
$ sudo apt-get install git-svn

¹ Ubuntu 14.04

How To

  1. Download svn dump from Google archive.
  2. Create a local svn repo by load the svn dump.
  3. Start svn daemon.
  4. Create authors.txt to map all svn users to git users.
  5. Create a bare git repo.
  6. git svn clone.
  7. Add git remote then push.
  8. Done.
$ wget https://storage.googleapis.com/google-code-archive-source/v2/code.google.com/your-google-code-project/repo.svndump.gz
$ gunzip repo.svndump.gz
$ svnadmin create /tmp/repo1
$ svnadmin load /tmp/repo1/ < repo.svndump
$ svnadmin --foreground -d

Start a new terminal Window

$ git svn --stdlayout -A authors.txt clone svn://localhost/tmp/repo1/
$ cd repo1
$ git remote add origin https://repo.git
$ git push --set-upstream origin master

authors.txt

Must map all svn users to git users.

user1 = user1 <[email protected]>
user2 = user2 <[email protected]>
(no author) = user3 <[email protected]>

Credits

@lincerely
Copy link

lincerely commented Jan 12, 2023

No need to serve the svn repo, as git-svn clone supports file protocol.

So instead of

svnserve --foreground -d
git svn --stdlayout -A authors.txt clone svn://localhost/tmp/repo1/

just:

git svn --stdlayout -A authors.txt clone file:///tmp/repo1/

Also, could include the --no-metadata option as this is a one-shot import.

Reference:https://www.gitkraken.com/blog/migrating-git-svn

@abitrolly
Copy link

abitrolly commented Apr 29, 2024

Update for copy/paste.

#!/bin/bash

set +x    # trace instructions

export GCPROJECT=fido2

cd /tmp
wget https://storage.googleapis.com/google-code-archive-source/v2/code.google.com/$GCPROJECT/repo.svndump.gz -O $GCPROJECT.svndump.gz
gunzip -v $GCPROJECT.svndump.gz

svnadmin create $GCPROJECT-svn
svnadmin load $GCPROJECT-svn --file=$GCPROJECT.svndump

svn log -q file:///tmp/$GCPROJECT-svn | awk -F '|' '/^r/ {sub("^ ", "", $2); sub(" $", "", $2); print $2" = "$2" <"$2">"}' | sort -u > $GCPROJECT-authors.txt

git svn clone --stdlayout -A $GCPROJECT-authors.txt file:///tmp/$GCPROJECT-svn $GCPROJECT
cd $GCPROJECT
echo $PWD

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment