Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

git

svn

migration

I've been working on moving our 9 projects in one SVN repo over to 9 separate git repos, managed on a server by gitolite then shutting down SVN. Seven of them were easy as they had no branches or tags so on my workstation I was able to do a simple:

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

Then pushed from my workstation to the gitolite sever via:

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

and they have all been working great. Now the final two projects are more difficult, having about 30 tags/branches each. After running the 'git svn clone' as above on one of those 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 do I go about getting all those tags/branches downloaded to my local workstation so I can push them through gitolite and shutdown the SVN server permanently? Is what I need to do in this guide, doing a 'git checkout -b' for each branch and tag? Should I be using svn2git or some other tool for this?

like image 540
xref Avatar asked Mar 07 '12 17:03

xref


People also ask

How do I clone an entire git repository including branches?

To clone a branch in a git repository, start by cloning the master repository using the git clone command. Once complete, navigate into the repo directory. The command will show the branches that are available in the local repository. To view even the remote branches, use the -a flag.

How do I push all branches from one remote to another?

Push a new Git branch to a remote repo Clone the remote Git repo locally. Create a new branch with the branch, switch or checkout commands. Perform a git push with the –set-upstream option to set the remote repo for the new branch. Continue to perform Git commits locally on the new branch.

Which migration is actually recommended for migration from SVN to git?

When moving to Git from another version control system like Subversion (SVN), we generally recommend that you perform a "tip migration", which migrates just the latest version of the repository contents, without including history.

How do I push to all branches?

To push the all branches to a remote git, we can use the git push command followed by the --all flag and origin. This will create a track with the local branches to the remote branches.


1 Answers

A helpful person in #git on freenode irc wrote me a little command to get my tags and branches copied over to Git from SVN:

Push 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 command which that prints out

Push 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 command which that prints out

like image 162
xref Avatar answered Nov 15 '22 21:11

xref