Alex Rivera | Logout

Converting svn to git, how to get the branches not to be just remote in the svn repo?

Asked 2009-10-18T11:43:10.887
17

I'm quite new to git and I'm trying to move a svn repository to git. I followed the guide below so now I have a git repo on my server
http://pauldowman.com/2008/07/26/how-to-convert-from-subversion-to-git/

So, if I do "git branch" git replies "* master" and if I do "git branch -r" i get a list of all the branches in the svn repository.

My last svn-checkins have been in one of the branches, but when I did the "git svn clone"-stuff my commits in that branch (they have not been merged into the trunk yet) are visible in my (git) master branch. What am I missing here?

Also, if I on my development machine do "git clone " I get the files alright. But if I do "git branch -r" I can only see the master branch and not the remote branches".

Since we're getting rid of the svn-repo all together I would like to have all the svn branches in the git-repo so that they can be accessed from the developer clients.

Again, I'm not a total git newbie but not far from it. So if there is something fundamental I'm missing here please tell me.

Update
After doing some RTFM (man git-svn) I solved the first problem with branch stuff present in the master branch

reset --hard remotes/trunk

Now the trunk and the master branch are the same. Now, next is to figure out how to get the branches from the development clients.

Update 2
I got it working by combining the url above and the url that Scott pointed to. So, from the beginning.

I first created an empty repository on the server, they are kept in /usr/local/git-repos on our server:

server> cd /usr/local/git-repos
server> mkdir my_project.git
server> cd my_project.git
server> git init

Then i cloned the svn-repository to my dev-machine (note, th

Edit
Report

1 Answer

18

There is a fairly detailed explanation on how to do a pretty good SVN import that explains how to convert the branches properly here:

https://git-scm.com/book/en/v1/Git-and-Other-Systems-Migrating-to-Git

The short answer is to run this:

$ cp -Rf .git/refs/remotes/* .git/refs/heads/
$ rm -Rf .git/refs/remotes

Hope that's helpful.

answered 2009-10-18T19:57:18.207

Your Answer