Migrate from Subversion to git, clone all branches and push gitolite?

I worked on moving our 9 projects in one SVO repo to 9 separate git repositories managed on a golith server, and then disconnecting SVN. Seven of them were lightweight, as they had no branches or tags, so on my workstation I was able to make simple:

git svn clone --stdlayout --no-metadata -A svnauthors.txt svn+ssh://user@host/var/subversion/project tempProject 

Then it is pushed from my workstation to the guitar with:

  git remote add origin ssh://gitolite@host/project git push -u origin master 

and they all work great. Now the last two projects are more complicated, having about 30 tags / branches each. After running 'git svn clone' as described above, in one of these projects I see:

 $ git branch -a * master remotes/BatchUpload remotes/clarify_breadcrumb remotes/contact_type remotes/contact_upload_improvements remotes/file_cabinet remotes/mobile remotes/summary_tiles remotes/summary_updates remotes/tags/release-2.1.2 remotes/tags/release-3.0.1 remotes/tags/release-3.0.2 remotes/tags/release-3.0.2c remotes/tags/release-3.1.1 remotes/tags/release-3.1.3 remotes/tags/release-3.1.4 remotes/tags/release-3.1.5 remotes/tags/release-3.1.5.UPDT remotes/tags/release-3.2 remotes/tags/release-3.2.1 remotes/tags/release-3.2.2.1 remotes/tags/release-3.2.3 remotes/tags/release-3.2.4 remotes/tags/release-3.2.6 remotes/tags/release-3.2.7 remotes/tags/release-3.2.7.1 remotes/trunk remotes/user_man_batch_upload remotes/user_management 

Now, how can I get all those tags / branches uploaded to the local workstation so that I can pass them through gitolite and shut down the SVN server forever? What do I need to do in this tutorial by doing "git checkout -b" for each branch and tag? Should I use svn2git or some other tool for this?

+8
git svn migration
source share
4 answers

A useful person in # git on freenode irc wrote a small command for me to copy my tags and branches to Git from SVN:

Insert branches:

 printf "git push origin "; git show-ref | grep refs/remotes | grep -v '@' | grep -v remotes/tags | perl -ne 'print "refs/remotes/$1:refs/heads/$1 " if m!refs/remotes/(.*)!'; echo 

Run a command that outputs

Click tags:

 printf "git push origin "; git show-ref | grep refs/remotes/tags | grep -v '@' | perl -ne 'print "refs/remotes/tags/$1:refs/tags/$1 " if m!refs/remotes/tags/(.*)!'; echo 

Run a command that displays

+11
source share

You can list all the remote links created when switching from svn to git: git show-ref (available from git 1.8. 2.2). Then decide to push them to their original position.

To list all links as branches at the beginning:

 git push origin refs/remotes/*:refs/heads/* 

To display tags at the beginning:

 git push origin refs/tags/*:refs/tags/* -or- git push origin --tags 

You may need to clear these branches or perhaps convert some branches to tags before / after clicking.

+1
source share

They are already on your local workstation. You only see links to commits, and you can check local branches by tracking them whenever you want.

 git branch -a 

Show information that is in your local repo, do not retrieve data from remote storage. You have all this information when you made a clone.

So, now that we have everything local, you only need to push the data to the remote computer. You can click all tags on the remote server with:

 git push --tags 

For each branch, you can click it on the repo with:

 git push origin remotes/BatchUpload:BatchUpload 
0
source share

Use svn2git. This will convert the tags to annotated git tags, and then them git push -tags

0
source share

All Articles