<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Refactored scope &#187; svn</title>
	<atom:link href="http://ominian.com/tag/svn/feed/" rel="self" type="application/rss+xml" />
	<link>http://ominian.com</link>
	<description>PyMethius project notes</description>
	<lastBuildDate>Mon, 06 Feb 2012 17:56:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Bridging the gap:  GIT &amp; SVN, B.F.F.</title>
		<link>http://ominian.com/2010/03/02/bridging-the-gap-git-svn-b-f-f/</link>
		<comments>http://ominian.com/2010/03/02/bridging-the-gap-git-svn-b-f-f/#comments</comments>
		<pubDate>Wed, 03 Mar 2010 05:24:29 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[howto]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[svn]]></category>

		<guid isPermaLink="false">http://ominian.com/?p=14</guid>
		<description><![CDATA[Background I&#8217;ve been using SVN for several years now, since late 2005 or early 2006, and its done me well since then. But a new darling has entered my life and its name is Git. I like git for some very specific reasons: It&#8217;s stupid easy to work with and as good or better then <a href='http://ominian.com/2010/03/02/bridging-the-gap-git-svn-b-f-f/'>[...]</a>]]></description>
			<content:encoded><![CDATA[<h3>Background</h3>
<p>  I&#8217;ve been using SVN for several years now, since late 2005 or early 2006, and its done me well since then.  But a new darling has entered my life and its name is Git.  I like git for some very specific reasons:  It&#8217;s stupid easy to work with and as good or better then SVN for reliability.  Also it helps that my preferred IDE, Komodo, recognizes and works with Git as well.<br />
   That said, I use google code for hosting my public projects and it only supports SVN and HG.  So one night I read up on git and noticed that it had a plugin/support for bridging to a SVN managed repo.  So began my journey.<br />
<span id="more-14"></span></p>
<p>!Note &#8211; I am using a client side credentials manager, if access to your repo requires authentication credentials you will need to supply them where appropriate.</p>
<h3>Initialization</h3>
<p>Bridging a new Git Repo to a new directory in SVN<br />
Step 1:</p>
<pre>
$svn mkdir https://devdave.googlecode.com/svn/trunk/javascript/canvastag/cnvLib

Committed revision 26.
</pre>
<p>      Now I&#8217;ve got a fresh/empty svn directory</p>
<pre>
   $git svn init https://devdave.googlecode.com/svn/trunk/javascript/canvastag/cnvLib
   Initialized empty Git repository in ~/dev/javascript/cnvLib/.git/
</pre>
<p>      Now I&#8217;ve got a local git repo that has most of the information I need for the bridge, to verify everything is hunky dory so far:</p>
<pre>
    $git svn fetch
    #r26 = a47a908ea96bec2d737f6646c47418778ce6ad32 (git-svn)
</pre>
<p><a href="http://ominian.com/wp-content/uploads/2010/03/cnvLib_initial.jpeg"><img src="http://ominian.com/wp-content/uploads/2010/03/cnvLib_initial-300x130.jpg" alt="Before the graft" title="Before the graft" width="300" height="130" class="alignnone size-medium wp-image-16" /></a></p>
<h3>Final steps, the graft</h3>
<p>Some tutorials out there say you should run git svn rebase or such, but doing so has gone poorly for me with results like </p>
<pre>
$ git svn rebase
      fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree.
      Use '--' to separate paths from revisions
      log --no-color --first-parent --pretty=medium HEAD: command returned error: 128
</pre>
<p>  I believe the problem relates to lining up your local Git repository with the remote SVN repository.   Unfortunately I was somewhat stuck in trying to figure out how the hell to fix this problem for a long time.  Fortunately Google search is the modern day version of a genie, it can grant you the information you seek, but first you have to know what to ask.  Which led me to finding <a href="http://eikke.com/importing-a-git-tree-into-a-subversion-repository/">this</a> blog post.</p>
<p>  I am not doing things &#8220;exactly&#8221; like the aforementioned blog, but close enough that I can get a similar result.</p>
<pre>
$ git show-ref
2a41e85e0dc264cfdb6c04b59547a3093c02f64f refs/heads/master
a47a908ea96bec2d737f6646c47418778ce6ad32 refs/remotes/git-svn
$ git log --pretty=oneline master
2a41e85e0dc264cfdb6c04b59547a3093c02f64f Initial import, copied from ping project
$ echo "2a41e85e0dc264cfdb6c04b59547a3093c02f64f a47a908ea96bec2d737f6646c47418778ce6ad32" >> .git/info/grafts
</pre>
<p><a href="http://ominian.com/wp-content/uploads/2010/03/cnvLib_aftergraft.jpeg"><img src="http://ominian.com/wp-content/uploads/2010/03/cnvLib_aftergraft-300x130.jpg" alt="After the Graft" title="After the Graft" width="300" height="130" class="alignnone size-medium wp-image-15" /></a>       </p>
<p>Since I am doing things a little odd/differently, there is no &#8220;trunk&#8221; branch available.  But the idea is close enough to duplicate.  I&#8217;ve already made some add/commit&#8217;s to my local Git repo but there isn&#8217;t a logical way to tell git/git-svn that this local commit also belongs to my remote SVN remote.  A more human friendly version of git show-ref is<br />
available via:</p>
<pre>
$ git branch -a
* master
  remotes/git-svn
</pre>
<p>So the concatenation of the two internal reference&#8217;s into .git/info/graft helps git-svn understand that the two separate repositories belong to each other.   Sometimes it&#8217;s nice when a configuration structure does what it&#8217;s called.</p>
<p>That said, on to the next obvious step, actually pushing changes from a local Git repo to SVN.</p>
<pre>
$ git svn dcommit
Committing to https://devdave.googlecode.com/svn/trunk/javascript/canvastag/cnvLib ...
        A       app.canvas.js
        A       app.input.js
        A       app.main.js
        A       app.mainloop.js
        A       app.shapes.js
Committed r27
        A       app.canvas.js
        A       app.mainloop.js
        A       app.input.js
        A       app.shapes.js
        A       app.main.js
r27 = ae1cd1055deffe4209ab89d1316c97336c731c39 (git-svn)
No changes between current HEAD and refs/remotes/git-svn
Resetting to the latest refs/remotes/git-svn
</pre>
<h2>What&#8217;s going on here?</h2>
<p>    As I am still learning the finer points of Git, it was important to me to understand what exactly .git/info/grafts does.  So turning to my favorite resource for arbitrary questions&#8230; I found an answer on Stack overflow: <a href="http://stackoverflow.com/questions/161928/what-are-git-info-grafts-for">What are git info grafts for</a>?   And a more official answer in the Git Wiki <a href="http://git.wiki.kernel.org/index.php/GraftPoint">http://git.wiki.kernel.org/index.php/GraftPoint</a></p>
]]></content:encoded>
			<wfw:commentRss>http://ominian.com/2010/03/02/bridging-the-gap-git-svn-b-f-f/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

