Git is becoming increasingly popular, which is why the need to migrate from legacy version control systems like CVS, SVN to Git is of great interest. In this tutorial, I will guide you all how to convert SVN repository to Git repository using the tool svn2git!
Install the svn2git tool
First, we need to install the svn2git tool.
The homepage of the svn2git tool is: https://github.com/nirvdrum/svn2git
svn2git is a tool written in the Ruby language. Therefore, we need to install Ruby first, then use Gem tool in Ruby to install the svn2git tool.
To install Ruby, you can refer to here!
After installing Ruby, you can use gem to install svn2git.
Open the command line and type the following:
1 |
gem install svn2git |
Here, we have installed the svn2git tool and be able to start converting an SVN repository to GIT repository!
Use the svn2git tool
The general syntax for using the svn2git tool is as follows:
1 |
svn2git <SVN_repository_URL> |
If your SVN repository needs to have a username and password to log in, then you use the following command:
1 |
svn2git <SVN_repository_URL> --username <username> --password <password> |
If your SVN repository does not follow the standard structure of an SVN repository (including trunk, branches, and tags), only has trunk and tags, then you use the following command:
1 |
svn2git <SVN_repository_URL> --trunk dev --tags rel --nobranches |
If your SVN repository does not follow the standard structure of an SVN repository (including trunk, branches, and tags) that only has trunk then you use the following command:
1 |
svn2git <SVN_repository_URL> --trunk trunk --nobranches --notags |
If your SVN repository does not follow the standard structure of an SVN repository (including trunk, branches and tags), then you use the following command:
1 |
svn2git <SVN_repository_URL> --rootistrunk |
And there are other options as well. You can refer to here.
For example, I need to convert the SVN repository of the cssparser library with SVN URL repository:
http://svn.code.sf.net/p/cssparser/code/trunk/cssparser
to Git repository, we will use the following command:
1 |
svn2git http://svn.code.sf.net/p/cssparser/code/trunk/cssparser --rootistrunk |
Result: