ailon's DevBlog: Development related stuff in my life

Steps to Migrate from Subversion to Git

3/1/2010 5:04:47 PM

I’ve migrated a couple of my SVN repositories to Git, but each time I forget how to do this. And each time I had to look into Pro Git book and process all the extra info there. So, I decided to document the steps I did for future reference. This is in no way a tutorial or something that has a good explanation of what’s going on. If you want to get a deeper information on the subject go read the book mentioned above.

I don’t work in a mixed SVN/Git environment so I only need to do this once for each project and forget about SVN on that project, so I figured I will document the steps and follow them blindly when I need to repeat the procedure for the next project. Note that this only migrates the trunk (or branch specified by the url) and doesn’t migrate tags, etc. If you need more than just a change log of your main branch, read the book/documentation.

So here we go.

  1. Create a directory for the new Git repository
  2. In that directory create a file called users.txt which looks like this:

    username = Real Name <>

    It’s used to match usernames in SVN commits to Git’s user information
  3. Run Git Bash in that directory and enter this command:

    git svn clone <svn-repository-url> --authors-file=users.txt --no-metadata

    Where <svn-repository-url> is the url of your SVN repository. If you use TortoiseSVN you can easily find this url by right clicking on your working copy and navigating to “TortoiseSVN->Relocate…” in the context menu.

    --authors-file tells Git to use your users file and --no-metadata tells it to omit metadata used by Git to synchronize repository with SVN. When you are migrating it’s quite important to use no-metadata as by default git-svn adds extra information to commit messages and you don’t want it.

And that’s basically it. However I do a couple extra steps to remove traces of SVN in my new Git repository.

Removing traces of SVN

Now I’m sure I don’t do this properly, but I couldn’t figure out how to do this the right way. So if you know how to do this from command line or some tool, please, let me know in the comments bellow.

  1. Remove sections [svn-remote …] and [svn] in file .git/config
  2. Delete file .git/refs/remotes/git-svn
  3. Remove directory .git/svn

As I said it’s not a good idea to mess with files in .git directory directly but I was unable to find commands to do this properly. So proceed on your own risk. It’s worth mentioning that this isn’t necessary, but for some reason these unneeded traces of SVN annoy me.

Tags: , ,

Merging SVN branch back to trunk with TortoiseSVN

3/31/2009 4:38:35 PM

This post is mostly a note to self, cause if I don’t do this for some time I forget how to do it and spend quite some time figuring things out. Actually this is quite a simple task but awkwardly implemented (from my point of view).

Now I did it for a second time in 2 weeks and managed to merge my branch back to trunk from the first attempt, so I decided it’s good ocassion to write things down so I don’t waste time the next time I forget the procedure.

So, here’s what you do after you are finished working on your branch and want to merge everything back to trunk:

  1. Make sure you’ve commited everything to your branch.
  2. Backup your whole working copy (just in case :)
  3. Switch your working copy to trunk: Right click->TortoiseSVN->Switch. Select your trunk URL, HEAD revision and press OK.
  4. Merge (this is the awkward part): Right click->TortoiseSVN->Merge. In from box select URL of your trunk (HEAD revision), uncheck Use “From:” checkbox in To section and select branch URL in To box. Test wit “Dry run” and press “Merge” if everything is correct.
  5. Commit to trunk

That’s it.

Bonus track: here’s a good article on minimizing merging conflicts when working on branches.

Tags: , ,

TortoiseSVN installation

10/23/2007 9:52:44 AM

For quite some time TortoiseSVN was shouting that I have to upgrade my installation cause I used a version which apparently had a security hole. After refusing to comply for some time I finally gave up. I've downloaded and installed version TortoiseSVN 1.4.5, Build 10425 which to my surprise, among other apps, required that I "exit" Windows Explorer!

I've killed all the "reasonable" applications it required but refused to do the same with Explorer and hit "Ignore". After the reboot TortoiseSVN couldn't launch stating (or was it Windows?) that "The application has failed to start because its side-by-side configuration is incorrect."

I needed to work with SVN badly, so I ran tortoise's installer again and ordered it to repair my installation. No surprise it asked again that I kill Windows Explorer. This time I complied (no matter how crazy this might seem) and it went "smoothly". I wonder when my whole system is going to crash...

I wonder if this is Vista-only issue or everyone has to kill Windows Explorer to install TortoiseSVN? Sounds completely nuts to me.

Tags: , , ,

Copyright © 2003 - 2018 Alan Mendelevich
Powered by BlogEngine.NET