SVN to GIT

From FIFE development wiki
Jump to: navigation, search

Cloning the SVN repo to GIT

Init your local git repo:

$ git svn init http://fife.svn.cvsdude.com/engine /data/repo/temp.git
$ cd /data/repo/temp.git
$ vi .git/config

Modify the git config to look like this:

[core]
       repositoryformatversion = 0
       filemode = true
       bare = false
       logallrefupdates = true
[svn-remote "svn"]
       url = http://fife.svn.cvsdude.com/engine
       fetch = trunk:refs/remotes/trunk
       branches = branches/{active,historic}/*:refs/remotes/branches/*
       tags = tags/*:refs/remotes/tags/*

Execute the following commands:

$ git svn fetch -r 824:HEAD --quiet
$ git svn show-ignore > .gitignore
$ git add .gitignore
$ commit -m "Convert svn:ignore properties to .gitignore."
$ git init --bare /data/repo/fife_repo.git
$ cd ../fife_repo.git
$ git symbolic-ref HEAD refs/heads/trunk   # I might have done this after the push. I cant remember now.
$ cd ../temp.git
$ git remote add bare ../fife_repo.git
$ git config remote.bare.push 'refs/remotes/*:refs/heads/*'
$ git push bare
$ cd ..fife_repo.git
$ git branch -m trunk master
$ git for-each-ref --format='%(refname)' refs/heads/tags | 
	cut -d / -f 4 |
	while read ref
	do
	  git tag "$ref" "refs/heads/tags/$ref";
	  git branch -D "tags/$ref";
	done
$ rm -rf ./temp.git

Done!