Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The remote branch from git-svn is pretty much the same as a regular Git remote. So in your local repository you can have your git-svn clone and push changes out to GitHub. Git doesn't care. If you create your git-svn clone and push the exact same changes out to GitHub, you'll have an unofficial mirror of the Google Code repository. The rest is vanilla Git.</p> <pre><code>git svn clone http://example.googlecode.com/svn -s git remote add origin git@github.com:example/example.git git push origin master </code></pre> <p>Now that you have this, occasionally you will have to synchronise the Subversion repository with Git. It'll look something like:</p> <pre><code>git svn rebase git push </code></pre> <p>In gitk or whatever, this would look something like this:</p> <pre><code>o [master][remotes/trunk][remotes/origin/master] | o | o </code></pre> <p>And when you run <code>git svn rebase</code>, you would have this:</p> <pre><code>o [master][remotes/trunk] | o | o [remotes/origin/master] | o | o </code></pre> <p>So now running <code>git push</code> would push those commits out to GitHub, the <em>[remotes/origin/master]</em> branch there. And you'd be back to the scenario in the first ASCII art diagram.</p> <p>The problem now is, how do you work your changes into the mix? The idea is, you don't ever commit onto the same branch that you are git-svn-rebase-ing and git-pushing. You need a separate branch for your changes. Otherwise, you would end up rebasing your changes on top of the Subversion ones, which could upset anyone who clones your Git repository. Follow me? OK, so you create a branch, let's call it "features". And you make a commit and push it out to GitHub to the features branch. Your gitk would look something like this:</p> <pre><code>o [features][remotes/origin/features] | o | o [master][remotes/trunk][remotes/origin/master] | o </code></pre> <p>Here you've got your features branch a couple of commits ahead of the Google Code branch, right? So what happens when you want to incorporate new stuff from Google Code? You'd run <code>git svn rebase</code> first and get this:</p> <pre><code> o [features][remotes/origin/features] [master][remotes/trunk] o | | o o / |/ o[remotes/origin/master] | o </code></pre> <p>If you <code>git push</code> master out, you can imagine the <em>[remotes/origin/master]</em> being at the same point as master. But your feature branch doesn't have the changes. Your choices now are to merge master into features, or rebase features. A merge would look like this</p> <pre><code>git checkout features git merge master o [features] /| / o [remotes/origin/features] [master] o | | o o / |/ o | o </code></pre> <p>Then you push features out to GitHub. I've left off the remotes for master to save space, they'd be at the same point as <em>[master]</em>.</p> <p>The rebase approach is slightly more evil - you'd have to push with --force as your push would not be a fast-forward merge (you'd pull the features branch from under someone who had cloned it). It's not really considered OK to do this, but nobody can stop you if you are determined. It does make some things easier too, such as when patches get accepted upstream in slightly reworked form. It'd save having to mess about with conflicts, you can just rebase --skip the upstreamed patches. Anyway, a rebase would be like this:</p> <pre><code>git rebase master features o [features] | o | o [remotes/origin/features] [master] o | | o o / |/ o | o </code></pre> <p>And then you would have to <code>git push --force</code> that. You can see why you need to force it, the history has a big old schism from the <em>[remotes/origin/features]</em> to the new current post-rebase <em>[features]</em>.</p> <p>This all works, but it is a lot of effort. If you are going to be a regular contributor, the best bet would be to work like this for a while, send some patches upstream and see if you can get commit access to Subversion. Failing that, perhaps don't push your changes out to GitHub. Keep them local and try and get them accepted upstream anyway.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload