Import from subversion - sauter-hq/git-guidelines GitHub Wiki

Use the following command to import data from an SVN repository :

apt-get install svn2git
mkdir repository-name/
svn2git https://hq.ch.sauter-bc.com/svn/repository-to-import --no-minimize-url --username your-username --metadata --authors authors-file --verbose

The authors-file is used to give a valid author name to the commits, it looks like the following :

czenemar = Martin Czene <[email protected]>
staudyan = Yannic Staudt <[email protected]> 
kraetyan = Yann Philipp Kraetzschmann <[email protected]> 
kraussve = Sven Krauss <[email protected]>
siebofab = Fabian Siebold <[email protected]>
eichsjul = Julian Eichstaedt <[email protected]>
eberldav = David Eberlein <[email protected]>
buhldam = Damien Buhl (alias daminetreg) <[email protected]>
truebden = Denis Trueby <[email protected]>
bouwerob = Robert Bouwens <[email protected]>
hoeneste = Stefan Hoene <[email protected]>
criticalvale = Nelson Vale <[email protected]>
frieddan = Daniel Friedrich <[email protected]>

Finally you have to rewrite the history, because in Fr. Sauter AG we did commits in the following form :

[FEATURE|BUG FIX|ADMIN|EDITORIAL]:

Commit description

This is a problem in Git view of history, as you only see the first line in summary views (and only the 50 first chars of this line). This is a convention backed by Git standards overview of logs and so on. You can convert the commits to this convention with the following sed script :

/\(^\(\(REFACTORING\)\|\(BUG\)\|\(BUGFIX\)\|\(FEATURE\)\)\s*:*\s*$\)\|\(^[^:]\+:\s*$\)/ , /^\s*[A\-Za\-z0\-9-]\+/ {
	
	:concat-lines-till-first-non-empty-line
	/\(^\(\(REFACTORING\)\|\(BUG\)\|\(BUGFIX\)\|\(FEATURE\)\)\s*:*\s*$\)\|\(^[^:]\+:\s*$\)/ {
		s/\s*$/ /g;
		N;
		s/\n//;
		bconcat-lines-till-first-non-empty-line
	}

	/^\s*[A\-Za\-z0\-9-]\+/! {
		N;
		s/\n//;
		bconcat-lines-till-first-non-empty-line
	}
	
}

Run through your freshly imported git repostory :

git filter-branch --msg-filter "sed -f ~/migrationSvnGit/rewriteMsg.sed" -- --all

Subversion imports scripts