Search code examples
gitsvngitlabgit-svn

How to migrate svn commit history or svn logs to gitlab


Objective: Migrate the SVN logs or SVN commit history to gitLab.

[Please note: Working in Windows] Successfully migrated the code from SVN to GIT via the following steps:

$ mkdir svn-migration
$ cd svn-migration
$ svn co <SVN-URL>

Retrieved the authors of SVN and stored into a file author.txt.

Format of authors.txt:

Pratim = Pratim <email-id>

Followed the following commands:

    $ git config --global user.name "PratimS"
    $ git config --global user.email "[email protected]"
    $ git config --global svn.authorsfile authors.txt
    $ git svn init <svn-url> --stdlayout
    $ git svn fetch

With this, the trunk source code folder from svn will be downloaded into my local directory.

$ git pull origin master
$ git remote add origin <git-url>
$ git push -u origin master

So I have successfully pushed all the source code to the Gitlab from the local repository.

Any suggestion on the procedure to fetch the svn logs or the commit history of the files in svn and then push it to the Gitlab, will be very helpful.


Solution

  • I found out the solution for the question raised.

    consider the following commands:

    $ mkdir svn-migration
    $ cd svn-migration
    $ git config --global user.name "PratimS"
    $ git config --global user.email "[email protected]"
    

    we need the authors.txt file to contain the information of all the members that committed the code in the svn in the format mentioned in the above description

    $ git config --global svn.authorsfile authors.txt
    $ git svn clone -r<1st revision number of the folder in svn>:HEAD --authors-file=authors.txt <SVN-URL> <Destination-Folder>
    

    This line retrieves all the commit history of all the files in the svn url and stores it into the destination folder. We can verify it by executing the command in the folder where the git cloned:

    $ git log <any file name>
    

    Next step is to push the files stored in the destination folder to the Gitlab:

    $ git pull origin master
    
    $ git add .
    
    $ git commit . -m "initial commit"
    
    $ git push -u origin master