|
ImportingFromGit
Import a Git repository to Google Code.
IntroductionYou can have Google Code act as a stable read-only Subversion mirror of a Git project. In this model, patches are first applied to the central Git repository and exported to Google Code later. Instead of merely providing a link to your repository, why not widen your audience with just a handful of commands? Open up your Git-hosted project to all Subversion users, whose patches can be integrated via Git. We presume some familiarity with Git, though blindly typing the commands below should produce acceptable results. 1. Create Subversion-aware Git cloneNaturally, your official source tree lives on some Git-capable server, which we denote by $GIT_REPO. http://code.google.com/hosting/createProject creating a new Google Code project, initialize an intermediary repository and fetch the Git tree: $ git svn clone --username you https://your-project.googlecode.com/svn/trunk $ cd trunk $ git fetch $GIT_REPO The Subversion repository must be nonempty. A new Google Code project contains one revision by default, but if you reset it, you should also create a first revision. Create a temporary branch for the fetched repository, and tag its head: $ git branch tmp $(cut -b-40 .git/FETCH_HEAD) $ git tag -a -m "Last fetch" last tmp 2. Apply initial commitUnfortunately, Git treats the initial commit specially, and in particular, cannot rebase it. Work around this as follows: $ INIT_COMMIT=$(git log tmp --pretty=format:%H | tail -1) $ git checkout $INIT_COMMIT . $ git commit -C $INIT_COMMIT 3. Rebase and submitApply all the other commits to the temporary branch, and make it the new master branch: $ git rebase master tmp $ git branch -M tmp master Lastly, commit the changes to Google Code: $ git svn dcommit To more faithfully represent deleted subdirectories and copies of unmodified files, run dcommit with the options \--rmdir and \--find-copies-harder. Be aware the latter option can be expensive. 4. Update Google CodeLater, export Git repository updates to Google Code as follows: $ git fetch $GIT_REPO $ git branch tmp $(cut -b-40 .git/FETCH_HEAD) $ git tag -a -m "Last fetch" newlast tmp $ git rebase --onto master last tmp $ git branch -M tmp master $ git svn dcommit $ mv .git/refs/tags/newlast .git/refs/tags/last For simplicity, we've exported directly to Google Code. It may be faster to first export to a local Subversion repository, and then mirror it to Google Code via svnsync. The content on this page created by Google is licensed under the Creative Commons Attribution 3.0 License. User-generated content is not included in this license. |
Sign in to add a comment
If a git-svn dcommit fails:
Repeat these steps until the commit completes normally. If the dcommit fails with some error, it will pick up where it left off.
I have a different way to do it. Was meant to keep an existing SVN repository updated but most of your setup instruction can be used as well.
http://repo.or.cz/w/nagiosplugins.git?a=blob;f=tools/git2svn.pl
It uses "git svn set-tree", but I believe the result is pretty much the same. The --add-author-from option in set-tree makes it possible to know who committed the code (I'm not sure if it can be done with your method).
Does anyone have an idea when google will support git in a direct way? I am perhaps in a large group of developers who have switched to git. I like the issue-tracking on googlecode, but it is starting to become tiresome, typing svn commands when my fingers now "know" git comments better. (git-svn is not much help; it's just a third set of commands for my fingers to type, and my goal is to reduce by one, not increase by one!)
git on googlecode would be awesome! c'mon fellas, why not (directly) supporting it?
Am I the only one unable to make the --rmdir flag work successfully ? I've been doing many git svn dcommit --rmdir but it still doesn't work. :(