Tutorial · Version Control
Migrate from SVN to Git in 7 Easy Steps
Move years of history to Git — every commit, author, and branch — without losing a thing.
A quick note before we start: this is a refreshed classic — one of the most useful posts from our old blog, brought over to the new site because the steps still hold up exactly.
If you're reading this, you're probably already sold on Git and looking to migrate. We were in the same spot: one of our repositories lived on a hosted SVN server, and we wanted to move to Git — but the repository had almost ten years of commit history, and losing that history was the one thing holding us back. The good news is that migrating from SVN to Git while keeping the full history is genuinely straightforward. Here's the exact process we used.
Note: most of these steps work from a Linux or Mac terminal. We did this from a Windows machine — if you're on Windows, we highly recommend the Windows Subsystem for Linux (WSL): learn.microsoft.com/windows/wsl.
git svn clone carries the full commit history across, and a little cleanup brings your branches and tags with it.Step 1 — Check everything into SVN
Make sure everything is committed to the SVN repository first. In practice that means telling your teammates to check in their pending changes too, so nothing gets left behind in the move.
Step 2 — Check out the repository from SVN
mkdir /gitmigration cd /gitmigration svn co <SVN repository url>
Replace <SVN repository url> with your hosted or local SVN repository. This creates a folder and checks the SVN repo out into it.
Step 3 — Collect every author who ever committed
Git records authors differently from SVN, so first pull the list of everyone who has committed over the life of the repo:
svn log -q | awk -F '|' '/^r/ {sub("^ ", "", $2); sub(" $", "", $2); print $2" = "$2" <"$2">"}' | sort -u > authors-transform.txt This writes every author into a new file, authors-transform.txt.
Step 4 — Fix up the authors list
SVN only gives you usernames, but Git expects authors in Author Name <email> format. Open
authors-transform.txt in any text editor and turn the bare usernames into full names and
emails — so a file that started as smokashi, user1, user2 becomes:
smokashi = Swanand Mokashi <[email protected]> user1 = Developer One <[email protected]> user2 = Developer Two <[email protected]>
Step 5 — Migrate
mkdir /gitFolder cd .. git svn clone <SVN REPO URL> -T. --authors-file=gitmigration/authors-transform.txt --no-metadata --prefix "" gitFolder
Replace <SVN REPO URL> with your SVN repository URL. When it finishes, your Git repository
is ready in the gitFolder folder. Confirm the history came across:
git log -n 3 --pretty=format:"%h - %an %ae %ar : %s"
That prints the last three commits — check that the authors look right for them.
Step 6 — Bring over branches and tags
If you have branches and tags in SVN, convert the imported remote refs into real Git branches and tags:
for t in $(git for-each-ref --format='%(refname:short)' refs/remotes/tags); do git tag ${t/tags\//} $t && git branch -D -r $t; done
for b in $(git for-each-ref --format='%(refname:short)' refs/remotes); do git branch $b refs/remotes/$b && git branch -D -r $b; done
for p in $(git for-each-ref --format='%(refname:short)' | grep @); do git branch -D $p; done
git branch -d trunk Step 7 — Push to your Git host
Assuming you've already created a remote repository on the host of your choice — GitHub, GitLab, Amazon CodeCommit, Azure — grab its clone URL and push:
git remote add origin '<GIT repo clone url>' git push origin --all
Replace <GIT repo clone url> with your clone URL. And voilà — your SVN repository is now
on Git, with all of its history intact.
Let's Talk About Your Project
A quick 30‑minute call is all it takes to find out if we're a good fit for each other. Book a time and we'll take it from there.