Migrate from SVN to Git

If you are in process of migrating from SVN to Git you are not alone and many people have already done it time and again. There are many good articles to guide you on that matter, the purpose of this article is to tell you my experience in the process.

Migration to git from SVN comprises of few steps:-
1)Getting contributors:-
                                    First step is to get the list of contributors from SVN, to do so right click to open git bash on source folder and  execute command below:-
svn log -q | awk -F '|' '/^r/ {sub("^ ", "", $2); sub(" $", "", $2); print $2" = "$2" <"$2">"}' | sort -u > authors-transform.txt
This may take a while so don't be disheartened git is doing its job and once done will output the file in command above.
If you get error saying SVN is not a known command you may not have SVN command line utility so you would like to install the same, if it is installed give complete path of the exe.

2)Format file obtained in step one:-
                                      The file obtained in step 1 would be vinayp = vinayp <vinayp> for each contributor, change each of this line to something like vinayp = Vinay Pandey <vinay@whateverdomain.com>

3)Clone SVN using git svn command:-
                                      Now go to target folder and execute command below to clone the svn in git format, git svn clone [SVN repo URL] --no-metadata -A authors-transform.txt --stdlayout ~/temp
When you do above you may end up with empty directory if your SVN is not in expected layout, so its safe to execute above command removing --stdlayout option.

This process may take longer depending on history in SVN and you may see that your screen is stuck with a message "Checked through rnumber". Don't worry and let it run it took 13 hours for me to execute.

5)Convert svn:ignore to .gitignore:-
                                      If you are using svn:ignore convert it to git ignore by executing below commands:-
git svn show-ignore > .gitignore
git add .gitignore
git commit -m 'Convert svn:ignore properties to .gitignore.'

6)Point to your remote repository:-

$ git remote add origin https://YourRepo    


7)Add all the newly migrated code:-

$ git push -u origin --all                                                      

In addition to above you can plan various other activities like what all binaries your want to transfer to package manager like nuget to make your source lighter.

Comments

Popular posts from this blog

RabbitMQ setup and cluster configuration on a windows network

Gitflow using source tree

Component analysis for application security

Analyse log using plug and play FileBeat

Introduction to Blazor

What Interview Is/Is Not for an interviewer

.NET MAUI and Blazor to create windows/web and mobile application (.NET 6.0)

Azure

WCAG Accessibility

Clean Architecture