Tuesday, 26 December 2017

TechTip - SVN to GIT Migration - Renaming/Refactoring Projects

During SVN to GIT Migration, I have faced one challenge that is renaming/restructuring projects while migration.

Let say, you have following maven project in SVN

-- src
-- pom.xml

Now you want this project to be renamed while migrating to GIT and it should look like below:

-- src
-- pom.xml

If you try changing this name while cloning projects from SVN to GIT just like below. You will loose history after migration. But you must think about solution where history remain as it is but your project can be renamed or restructured.

git svn clone --trunk=/trunk --branches=/branches --branches=/bugfixes --tags=/tags --prefix=origin/ --authors-file= svn-committer.txt  svn://xyz.com/SRC/Trunk/old-project new-project

How to do it? 

Actually, there is no rocket science I have applied here. Its pretty simple. You just need to refactor/rename your projects in SVN itself. The good part is, SVN still maintains full history even after renaming the folder names while copying from one place to another. This is really one of the great features in SVN that I will miss in GIT for sure.

First copy your project in SVN itself with required name using below command

svn copy <source-svn-url>   <destination-svn-url> -m "Renamed project name"


svn copy svn://xyz.com/SRC/Trunk/old-project  svn://xyz.com/SRC/GIT-SRC/new-project -m "Renamed project name from old-project to new-project"

Do whatever refactoring you want to do with your project in SVN itself. Now once you are ready with structure of your  project which must be there in GIT as repository, you can use your refactored location to clone project.

git svn clone --trunk=/trunk --branches=/branches --branches=/bugfixes --tags=/tags --prefix=origin/ --authors-file= svn-committer.txt  svn://xyz.com/SRC/GIT-SRC/new-project new-project

After migration in GIT, you can see full change history of old-project including message 'Renamed project name from old-project to new-project' that you just did while renaming the project in SVN itself from old to new location.

Renaming/Refactoring was a big challenge but with this simple approach I could successfully renamed/refactored projects while SVN to GIT migration.

If you are looking for post about how to migrate from SVN to GIT. You can refer my another post.