Skip to content

Instantly share code, notes, and snippets.

@eggplants
Forked from yancyn/git-svn.md
Last active July 20, 2024 00:45
Show Gist options
  • Save eggplants/b7122f051f62ff1346b6dafe063f1119 to your computer and use it in GitHub Desktop.
Save eggplants/b7122f051f62ff1346b6dafe063f1119 to your computer and use it in GitHub Desktop.
Migrate Archive Google Code SVN to Git

Migrate Archived Google Code SVN to GitHub Git (in 2023)

This document was forked from https://gist.github.com/yancyn/3f870ca6da4d4a5af5618fbd3ce4dd13.

Requirements

  • wget
  • git
  • git-svn

Setup

# Ubuntu 23.04
sudo apt install -y wget git git-svn

authors.txt

Must map all svn users to git users.

# Syntax: "svn author name" = "github username" <github mail address>
# TIPS: You can see the list of commits by each svn authors.
# https://code.google.com/archive/p/foo-project/source/default/commits
user1 = user1 <[email protected]>
user2 = user2 <[email protected]>
(no author) = user3 <[email protected]>

How To

SVN_PJ_NAME='foo-project'
GIT_PJ_NAME='foo-project-archive'
YOUR_GH_URL='https://github.com/torvalds'

# Download svn dump from Google archive.
wget "https://storage.googleapis.com/google-code-archive-source/v2/code.google.com/${SVN_PJ_NAME}/repo.svndump.gz"
gunzip repo.svndump.gz

# Create a local svn repo by load the svn dump.
svnadmin create "$SVN_PJ_NAME" && svnadmin load $_ < repo.svndump

# Start svn daemon.
svnserve --foreground -d -r . &

# Create a bare git repo.
git svn clone -s -A authors.txt "svn://localhost/${SVN_PJ_NAME}" "$GIT_PJ_NAME"

# Add existing remote git repo then push.
pushd "$GIT_PJ_NAME"
git remote add "${YOUR_GH_URL}/${GIT_PJ_NAME}"
git push -u origin master
popd

# Kill daemon.
kill %1

# Remove SVN and dump file.
rm -rf "$SVN_PJ_NAME" repo.svndump

Credits

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