Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to migrate an SVN repo on Google Code to a git repo on GitHub

Tags:

git

github

svn

I'm having difficulties switching from an SVN repository hosted on code.google to a git repo on github. Specifically:

  1. How can I change code on code.google from SVN to GIT while keeping the revision history?
  2. How can I change the wiki on code.google from SVN to GIT while keeping the revision history?
  3. How can I move my GIT repository from code.google to GitHub?
  4. How do I keep both repositories in sync with each other, while still using GitHub as the primary repo?
like image 726
Justin Avatar asked Nov 21 '13 17:11

Justin


1 Answers

Variables:

  • $project is your project name
  • $username is your username on github

This assumes that your $project name is the same on github as it is on code.google and you have already initialized your github repository.

Also, if your code.google repository is already GIT, you can skip to step 4.

  1. Convert project from SVN to GIT. This is as easy as going into the Administration->Source tab and change it from SVN to GIT. By the way, the svn is still available after you do this; so don't worry about a complete code loss.

  2. Convert source from code.google SVN to code.google GIT (keeping history)

    git svn clone --stdlayout https://$project.googlecode.com/svn $project
    cd $project
    git remote add googlecode https://code.google.com/p/$project
    git push --all googlecode
    cd ..
    
  3. Convert wiki from google SVN to google GIT (keeping history)

    git svn clone https://$project.googlecode.com/svn/wiki $project.wiki
    cd $project.wiki/
    git remote add googlecode https://code.google.com/p/$project.wiki
    git push --all googlecode
    cd ..
    
  4. Get new git repo from github

    mkdir github
    cd github/
    git clone https://code.google.com/p/$project.git
    cd $project/
    
  5. Get source from code.google GIT to local github clone

    git remote set-url origin https://github.com/$username/$project.git
    git pull
    
  6. Push source from local clone to github

    git push origin master
    
  7. Tell your local clone to push commits to github AND code.google

    git remote set-url --add origin https://$project.googlecode.com/git
    
  8. Test pushing commits to both github and code.google

    touch test.txt
    git add test.txt
    git commit -m "Testing repo replication" test.txt
    git push
    

Now, whenever you make changes to your local clone, it'll push those changes to both repositories.

Note: If you clone again in another location (like a different computer), you'll have to repeat step 6 again.

like image 102
Justin Avatar answered Sep 19 '22 14:09

Justin