My favorites | Sign in
Project Home Wiki Issues Source
Search
for
ConvertingSvnToGit  
Moving a project from using Subversion for code hosting to Git
git
Updated Mar 26, 2013 by jasonhall@google.com

Convert your project from Subversion to Git

Follow the following instructions to switch your project from Subversion to Git:

  1. Go to your existing open source project, choose the Administer tab, and then choose the Source sub-tab.
  2. Change the repository type to Git
  3. Import your code into the Git code repository as described in the 'How to Convert Subversion History to Git' section below
  4. In the same manner you imported your code, import your wiki into the Git wiki repository. Make sure to use the path of the wiki in your subversion repository (e.g. http://projectname.googlecode.com/svn/wiki) and the Hg wiki repository (http://code.google.com/p/projectname.wiki/)

Your old Subversion project will still be accessible after you switch your project to using Git, so you will not need to back up your repository before switching. Your Subversion repository will remain accessible at: https://projectname.googlecode.com/svn/

Until you convert your old Subversion data to Git, your new repository and wiki will appear empty. (Don't worry, your old Subversion data is still there, and you can always switch back.)

How to Convert Subversion History to Git

For both of these options, make sure you know your project's clone URL and familiarize yourself with the clone instructions on your project's Source Checkout page. You can get to this page by clicking the "Source" tab, or go directly to https://code.google.com/p/projectname/source/checkout

You won't be using the git clone instructions exactly for this procedure, but you should be using that URL and username/password info.

Option 1: Top-Skimming

If you don't care about your project's history, then you can simply "top skim" the latest trunk code or wiki from Subversion and put it into Git. Assuming your googlecode Git repository is empty, it's as easy as:

  $ git clone https://code.google.com/p/projectname
  $ cd projectname
  $ svn export --force http://projectname.googlecode.com/svn/trunk .
  $ git add .
  $ git commit -m "Initial import of source."
  $ git push origin master

To convert your wiki:

  $ git clone https://code.google.com/p/projectname.wiki
  $ cd projectname.wiki
  $ svn export --force http://projectname.googlecode.com/svn/wiki .
  $ git add .
  $ git commit -m "Initial import of wiki."
  $ git push origin master

Option 2: Full History Conversion

If want to migrate your whole history, the process is much more involved. We will use a tool called git-svn, which is included in standard Git distributions.

The steps below work best if you use the standard Google Code Subversion project layout, with /trunk, /branches, /tags, and /wiki directories.

git-svn is a powerful tool that is capable of much more than the simple history conversion we will go through here. For more information, see the full documentation.

Converting your history can be as simple as cloning the Subversion repo using the svn remote helper:

  $ git svn clone --stdlayout https://projectname.googlecode.com/svn projectname
  $ cd projectname
  $ git remote add googlecode https://code.google.com/p/projectname
  $ git push --all googlecode

If your project has tags, you should also push those. The following will create a simple tag for every tag in the Subversion repo. If you want to create annotated tags, the procedure can be more complicated; see http://gitready.com/advanced/2009/02/16/convert-git-svn-tag-branches-to-real-tags.html for a brief example.

  $ git push googlecode refs/remotes/tags/*:refs/tags/*

To convert your wiki history, use a similar approach (note the .wiki suffix):

  $ git svn clone https://projectname.googlecode.com/svn/wiki projectname.wiki
  $ cd projectname.wiki
  $ git remote add googlecode https://code.google.com/p/projectname.wiki
  $ git push --all googlecode

You're done! If you look at your project's Source or Wiki tabs, you should see your converted repository history.

If you have trouble, feel free to contact google-code-hosting@googlegroups.com

Comment by stuart.f...@gmail.com, Aug 22, 2011

The full history conversion instructions do not work.

$ git remote add googlecode https://code.google.com/p/projectname
fatal: Not a git repository (or any of the parent directories): .git

If I try cd-ing to projectname first and then running this command it works but then the the push command doesn't:

$ cd projectname/
$ git remote add googlecode https://code.google.com/p/projectname
$ git push --all googlecode
error: Cannot access URL https://code.google.com/p/projectname/, return code 22

The actual commands I ran contained my project name, obviously.

Comment by robertop...@gmail.com, Aug 25, 2011

The "Cannot access URL" error is caused because git push requires an authenticated connection; there are 2 ways to do this. You can put your username in the URL like this

$ git remote add googlecode https://user@code.google.com/p/projectname

or you can add a line to your .netrc file.

Comment by drey...@gmail.com, Oct 10, 2011

I seeing below error:

$ git push --all googlecode error: SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed while accessing https://code.google.com/p/drupalcamplagos/info/refs

fatal: HTTP request failed

Any ideas what could be wrong?

Comment by john.douglas.pritchard, Mar 17, 2012

Works well, full history. Admin>Source>Git; then Option 2.

Comment by drewnoakes, May 18, 2012

The link to the git-svn documentation is broken: http://www.kernel.org/pub/software/scm/git/docs/git-svn.html

Comment by amine.be...@gmail.com, Mar 19, 2013

I face the following error : RA Layer request failed on '/' : PROPFIND of '/' : 405 method not allowed https://my_project_URL at /usr/lib/perl5/site_perl/Git/SVN.pm Line310

any leads please ???

Comment by a...@1stleg.com, Sep 27, 2013

#$ git push googlecode refs/remotes/tags/:refs/tags/ Counting objects: 625, done. Delta compression using up to 12 threads. Compressing objects: 100% (268/268), done. Writing objects: 100% (577/577), 371.30 KiB, done. Total 577 (delta 337), reused 478 (delta 282) remote: Scanning pack: 100% (577/577), done. remote: Error: internal server error error: RPC failed; result=56, HTTP code = 200 fatal: The remote end hung up unexpectedly fatal: recursion detected in die handler Everything up-to-date

Instructions do not completely work....

Comment by sun818524@gmail.com, Mar 18, 2014

7777

2014-02-05 21:44 GMT+08:00 <support@googlecode.com>:

Powered by Google Project Hosting