Migrating from SVN to Git

Using a live SVN repository

1] Create directory for the git project. Navigate to the directory and do
git svn init -t tags -b branches -T trunk [svn-repo-url]
eg: git svn init -t tags -b branches -T trunk https://subversion.assembla.com/svn/my-repo-name/

and then do a
git svn fetch
This will download all the commits in git. If you get this error

error 0: REPORT request failed on ‘/svn/project-name/!svn/vcc/default’: Path https://Asloob-PC/svn/project-name is not canonicalized; there is a problem with the client.

its because of upper case letters in the url. In this case, my svn was hosted in Visual SVN server locally and the url was https://Asloob-PC/svn/my-project/ I just changed it to https://127.0.0.1:443/svn/my-project/.  Do confirm the port no.

2] Push to git server
Create a repository on GitHub / Bitbucket / Any other git service  and push the changes
git remote add origin https://asloobq@bitbucket.org/asloobq/my-project.git
git push -u origin –all

Using a svn dump file

If you want to migrate a svn dump file to git use the following method. Basically we are going to host it locally on Visual SVN server and then use the above method. Do install Visual SVN server before proceeding.

1] Creating SVN repository from dump the file.
On command prompt go to the path where svn repositories are stored . For me its G:\Applications\Repositories
svnadmin create [project-name]
svnadmin load > [dump-file-path]
Use lower case characters for name of the repository. Launch ‘Visual SVN server’ and check if the repository is shown. Copy the repository url

2] Migrate to git
Use the above method to migrate using the live svn repository.

Leave a comment