A decision made
A couple of months ago we started the process of moving our SVN repositories to GIT. Consequently, we made the decision to move all of our SVN repositories to GIT. Looking at the initial SVN to GIT process, we had a few stumbling blocks. Finally, what we went with is the awesome little lib SVN2GIT written in .Net Core, making it cross-platform as well.
There are some pieces of software that are required for this to work, so let us get started and get everything installed. I am running windows so I will make sure this works on my machine but it should be the same (‘somewhat’) on other systems. First we need Subversion, this will be used to read from the SVN repository. Make sure that you can access the “svn” command from the command line. Next we need GIT, to do the GIT side of things. Also make sure that “git” command is available from the command line. Download and install SVN2GIT and see if you can run the ‘svn2gitnet –help’ to verify installation.
Getting all the authors
The first thing I had to do is get all the authors that worked on the SVN repositories and find, or set their counterparts in GIT. For example, if stephang worked on the repository in SVN, the commit would be set to firstname.lastname@example.org. This authors file can most probably be generated from the SVN repository, but I went the painful way, and, because most of our authors are mostly the same, it was not that painful for me in the end.
- Create a git repo on your remote system (ie BitBucket/Github/Gitlab)
- Mark the SVN repo as read-only.
- Make a new folder ie:
- Copy over the authors.txt file to the new folder.
- In the new folder run the command of the svn2git which reflects your SVN repo structure the best, in my case it was something like:
svn2gitnet http://reposerver/svn/reponame --trunk Source/Live --branches Source --notags --authors authors.txt --username SVNUsername --password SVNPassword
You can have a look at the documentation to see what tags are allowed.
- After it has completed you should be able to push to the remote repo that you set up in the first step
cd existing_repo git remote rename origin old-origin git remote add origin email@example.com git push -u origin --all git push -u origin --tags
Checks after pushing to the remote
It may be a good idea to also do some setup of the repo after you pushed the code. Stuff like setting up the default branch and protecting branches should be done as soon as possible to prevent some mishaps that can occur in switching to a new version control system.
And we should be done. Hope this helped, if you have any other tips and or tricks, please share.