Skip to content

Instantly share code, notes, and snippets.

@sunilchaurha
Forked from aamine/MigrateSubversionToGitHub
Last active July 17, 2018 12:51
Show Gist options
  • Save sunilchaurha/7d86e5213fea8c59d4ee665e1c345fb7 to your computer and use it in GitHub Desktop.
Save sunilchaurha/7d86e5213fea8c59d4ee665e1c345fb7 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
*In few cases when this migration is not done properly and we want to delete master branch/tags from git, then below are the steps can be followed.*
1. Got to project created in git/gitlab
2. Create a 'dummy' branch
3. Click on settings in the left side menu
4. Expand to 'general project settings'
5. Seleft the default branch as 'dummy'
6. Go to project and select the requied branch to be delete (i.e. master, or any tag)
7. After rectification of error, perform above steps.
8. Got to git/gitlab browser and make 'master' as default.
9. Delete 'dummy' branch.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment