Skip to content

Instantly share code, notes, and snippets.

@aamine
Last active March 3, 2021 12:49
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save aamine/5284633 to your computer and use it in GitHub Desktop.
Save aamine/5284633 to your computer and use it in GitHub Desktop.
How to migrate Subversion repository into GitHub with all history, all branches, all tags, using standard layout and temporary bare git repository.
1. Write Authors.txt, which maps Subversion user ID to Git user.
For example:
taro = Taro Yamada <taro@example.com>
2. Create temporary, local, bare Git repository and map Subversion branches and tags.
$ git --bare init proj.git
$ cd proj.git
$ cat <<. >> config
[svn-remote "svn"]
url = <Your Subversion Repository URL here>
fetch = trunk:refs/heads/master
branches = branches/*:refs/heads/*
tags = tags/*:refs/tags/*
.
$ git --bare svn fetch -A ../Authors.txt # Takes long...
3. Push all contents to GitHub
$ git --bare remote add origin https://github.com/your_account/your_project.git
$ git config branch.master.remote origin
$ git config branch.master.merge refs/heads/master
$ git push -u origin master
$ git push --all
$ git push --tags
@sunilchaurha
Copy link

Format of the Authors.txt has to be as below:
svn_user_name = JustNameInGit obligatory@email.com

@rawatds
Copy link

rawatds commented Mar 3, 2021

Hi all,

You do not need to create Authors.txt manually, rather you can get the list of all authors who have committed in the svn repo as:

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

Hope it will help!

Thanks
Dharmender

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