Skip to content

Instantly share code, notes, and snippets.

@ritcheyer
Created October 25, 2012 21:45
Show Gist options
  • Save ritcheyer/3955631 to your computer and use it in GitHub Desktop.
Save ritcheyer/3955631 to your computer and use it in GitHub Desktop.
Porting an SVN Repo to Git with SVN History Intact

Introduction

There are a number of resources online that are helpful in documenting the flow of converting your entire SVN Repo (including all history) to Git. This documentation was derived from two locations:

Get Authors

cd /path/to/svn/repo
svn log -q | awk -F '|' '/^r/ {sub("^ ", "", $2); sub(" $", "", $2); print $2" = "$2" <"$2">"}' | sort -u > /path/to/authors.txt

Update format on authors.txt

Convert from this format: user = user <user>
To this format: user = UserFirst UserLast <user@website.com>

Clone SVN Repo into Git

git svn clone [SVN REPO URL] --no-metadata -A /path/to/authors.txt name-of-new-repo

convert svn:ignore to .gitignore

cd /path/to/temp/repo
git svn show-ignore > .gitignore
git add .gitignore
git commit -m "Converting svn:ignore properties to .gitignore"

push repo to public/private repo

git remote add origin somegitusername@somegithostingwebsite:userid/project.git
git pull origin master
git push origin master --tags
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment