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

gitgit-svnsvn

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, that on our svn server the "branches" dir is called "branch" witout the 's'):

dev> git svn clone http://<svn.server>/my_project --no-metadata -A authors.txt -t tags -b branch -T trunk my_project

Then some clean-up to get the tags and branches in order:

dev> cp -Rf .git/refs/remotes/tags/* .git/refs/tags/
dev> rm -Rf .git/refs/remotes/tags
dev> cp -Rf .git/refs/remotes/* .git/refs/heads/
dev> rm -Rf .git/refs/remotes

Now add my server as a remote repository:

dev> git remote add origin jorgen@<our_server>:/usr/local/git-repos/my_project.git

Finally, push all branches and tags up to the server:

dev> git push origin --all

Phew, now there you have it, now I can get rid of that svn-repo.

Update 3
Checkout ebneters post below for an easier way of doing it…

Best Answer

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.