Sunday, January 27, 2019

Migrate SVN repository to GIT

These are the steps that i followed during the SVN migration to GITHUB repository. svn2git is the utility that i used for this migration.


Prerequisites


 1. You should have git, git-svn and ruby installed. To verify execute below command

sudo apt-get install git-core git-svn ruby
  
2. Install svn2git using following command.

sudo gem install svn2git

Usage:
  • Checkout your svn repository to your local machine by executing below command. 
svn checkout 'repoName' --username 'userName'

  • Execute below command to extract the list of sub version committers. 
svn log -q | awk -F '|' '/^r/ {sub("^ ", "", $2); sub(" $", "", $2); print $2" = "$2" <"$2">"}' | sort -u > authors-transform.txt

  •  Run svn2-git utility (Pass the authors-transform.txt file)
svn2git 'repositoryName' --username 'username' --authors authors-transform.txt

 Note:  If the svn repository is a standard layout of (trunk, branches, tags) at the root level. So doesn't require any addional parameters while using svn2git command.  
  • Once the above command completes you shoud get a local git repository similar to your svn repository. 
  • Add remote origin using below command. 
git remote add origin git@github.com:Company/RepoName.git
  • Push master, all the other branches.
git push origin master
git push origin --all
  • Push Tags to remote git repository by execuing following command. 
git push origin --tags