Child pages
  • Straight-forward svn to git migration with TortoiseSVN or Linux git

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Added Linux commands

...

In such a case, you can use TortoiseGit for Windows to achive a svn to git migration. The beauty in this is that developers may already be used to the Tortoise tools from TortoiseSVN.

Info

A different, much better aproach is, of course, to migrate in a Linux machine, if you can obtain a Linux box in the company or install VirtualBox locally on your desktop. In this case, a very good migration

receipe

recipe is: https://www.atlassian.com/git/tutorials/migrating-overview. The basic commands are listed below.

Table of Contents

TortoiseGit approach

Installation

First, install TortoiseGit from https://tortoisegit.org/download/.

This can be done with local Windows admin privileges, no domain admin is needed.

Clone the SVN repository into Git

The next step is to create a local git repository on your machine and to import the svn repository into it. This can be done in one step in TortoiseGit, you don't have to create an empty repository first. You just clone the svn repo by selecting "Git clone" from teh Windows Explorer context menu in a fresh folder on your Windows machine.

...

You may refresh (like svn update) yout git repository from svn any time by issueing "SVN fetch" from the TortoiseGit context menu on your new git repositry.

Check the repository

You may check the contents in your local git repository before you upload them. This can be done with the TortoiseGit "Show Log" function:

Push your git repository

In the next step, you can push your new git repository to a remote git server.

...

You cann always repeat this process: Fetch new updates from the (still current) svn server, and push the changes to the remote git repository.

...



Linux, git and Atlassian approach

These suggested commands assume a (German) ISO-8859-charset SVN repository to be converted.

Preparation

  • Download the Atlassian migration Java class.
  • Verify functionality: java -jar ~/svn-migration-scripts.jar verify
  • Extract author information: cd ~/GitMigration; java -jar ~/svn-migration-scripts.jar authors <svn-repo> > authors.txt
  • Edit the authors.txt file to include the correct names and email addresses

Migration

Convert your svn repository to a new git repository:


Code Block
cd ~/GitMigration/
git svn clone --trunk=trunk --branches=branches --tags=tags --prefix "" --authors-file=authors.txt <svn URL> <svn repo name>
cd <repo name>
java -Dfile.encoding=iso-8859-1 -jar ~/svn-migration-scripts.jar sync-rebase

Don't forget the --prefix option wich overcomes a bug leading to an "fatal: ambiguous argument 'remotes/trunk': unknown revision or path not in the working tree" error.

Clean the new repository:

Code Block
java -Dfile.encoding=iso-8859-1 -jar ~/svn-migration-scripts.jar clean-git

Push local git repo to git server

Add a new (company) git server to your local git repo:

Code Block
git remote add origin <your git server url>

To push your local repo to this server:

Code Block
git push -u origin --all

Synchronization

To synchronize the still-current svn repo with your git server, you may create a cron job like this:


Code Block
cd ~GitMigration/<reponame>
git svn fetch
java -Dfile.encoding=iso-8859-1 -jar ~/svn-migration-scripts.jar sync-rebase
java -Dfile.encoding=iso-8859-1 -jar ~/svn-migration-scripts.jar clean-git --force
git push -u origin --all


See also: