IT-Knowledge-Base

GIT in front of SVN

Nowadays, more and more people talk about GIT as a new version control system. The first time I heard about git, was maybe last year. After watching several videos, e.g. "Tech Talk: Linus Torvalds on git" and "Introduction to Git with Scott Chacon of GitHub" I felt confident to start with GIT. Originally my favorite control system was SVN, so I searched for a solution to switch or combine both together.

I was realy surprised to find out that it was so easy.

git svn clone -s https://domain.world/svn/example
-s means your repository has the normal svn layout: trunk, tags, branches
It is also possible to specify the location if your repository use a different layout.

After downloading and building a Git-Repository out of your SVN data, you will get a folder named by the svn project (exmaple) containing a hidden folder named “.git” and the HEAD of your Svn-Repository. Inside of “.git” you can find a file named “config”. There are some configs for this project, interesting are all remote locations. The first location will point to our svn project.

[svn-remote "svn"]
	url = https://domain.world/svn/example
	fetch = trunk:refs/remotes/trunk
	branches = branches/*:refs/remotes/*
	tags = tags/*:refs/remotes/tags/*

GIT needs that location for “git svn rebase” and “git svn dcommit

What to do after cloning

From now on, you can work within your local repository as you would work within a normal git-clone. That means you can branch, checkout, merge and commit.

If you decide you have reached a step where you want to share your code by committing it to the origin svn repository, you simply have to do the following steps.

First go to your master branch, it has to be at latest version, make:

git svn rebase
After this command git-svn will update your master branch with the head of your svn-origin.
Next do:
git svn dcommit
This will step by step commit every commit you did with git to your svn-origin. So after this step your master will be the same as your svn-origin. Developers who works centralized with svn, will see all commits you did with git, inside of the svn-history. To avoid that, what is not really necessary, you can squash local commits to increment the svn-head only once.

~~DISCUSSION~~

This website uses cookies for visitor traffic analysis. By using the website, you agree with storing the cookies on your computer.More information