简体   繁体   中英

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

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?

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.

There is now an export feature on Google Code - go to your project's Google Code page ie code.google.com/p/yourproject then you should see a button 'Export to GitHub' which will do it in a couple of steps (note: you will need to authorize it with your GitHub account).

Note that you can do this for any project, not just your own.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM