<?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>Live &#38; Code &#187; svn</title>
	<atom:link href="http://www.liveandcode.com/tag/svn/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.liveandcode.com</link>
	<description>Enrico on programming, living, and everything in between</description>
	<lastBuildDate>Mon, 27 Jun 2011 01:10:34 +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>From Git to SVN</title>
		<link>http://www.liveandcode.com/2009/05/27/from-git-to-svn/</link>
		<comments>http://www.liveandcode.com/2009/05/27/from-git-to-svn/#comments</comments>
		<pubDate>Wed, 27 May 2009 17:00:45 +0000</pubDate>
		<dc:creator>Enrico</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[how to]]></category>
		<category><![CDATA[svn]]></category>

		<guid isPermaLink="false">http://www.liveandcode.com/?p=26</guid>
		<description><![CDATA[There are many blog posts that talk about how to import a Subversion repository into Git but there isn&#8217;t much out there on how to work the opposite way.  After a bit of trial and error, I managed to figure out how to bring a Git repository into SVN and continue &#8220;pushing&#8221; updates from Git [...]]]></description>
			<content:encoded><![CDATA[<p>There are many blog posts that talk about how to import a Subversion repository into Git but there isn&#8217;t much out there on how to work the opposite way.  After a bit of trial and error, I managed to figure out how to bring a Git repository into SVN and continue &#8220;pushing&#8221; updates from Git to SVN.</p>
<p>This might raise some questions for fervent Git fans: Why would anyone want to do this? Why not just keep everything in Git?</p>
<p>Here&#8217;s a personal anecdote: I developed a plugin for WordPress called <a href="http://wordpress.org/extend/plugins/gitpress/">GitPress</a>. My initial development was done on GitHub, but in order for my plugin to be available via the WordPress Plugins Directory, I needed to bring everything from GitHub into WordPress&#8217; SVN repository.  Here&#8217;s how I did it:</p>
<p>First, we create the initial SVN remote.  By using the standard layout (<code>--stdlayout</code>) and specifying the &#8220;gitpress/&#8221; prefix, I can easily get tracking branches for SVN branches, tags, and trunk.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">git</span> <span style="color: #c20cb9; font-weight: bold;">svn</span> init <span style="color: #660033;">--stdlayout</span> <span style="color: #660033;">--prefix</span>=gitpress<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #660033;">--username</span>=enricob http:<span style="color: #000000; font-weight: bold;">//</span>svn.wp-plugins.org<span style="color: #000000; font-weight: bold;">/</span>gitpress</pre></div></div>

<p>Now, I fetch everything from the SVN remote that I&#8217;ve created and see if the remote branches are there:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">git</span> <span style="color: #c20cb9; font-weight: bold;">svn</span> fetch</pre></div></div>

<p>Now, when I list my remote branches in Git, I see gitpress/trunk, gitpress/tags, and gitpress/branches.  I create a local tracking branch for gitpress/trunk, which is where I&#8217;ll be pushing my changes:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">git</span> checkout <span style="color: #660033;">-b</span> svn-trunk gitpress<span style="color: #000000; font-weight: bold;">/</span>trunk</pre></div></div>

<p>Now that I&#8217;m in my new tracking branch, I bring in the changes from my Git repository&#8217;s master branch:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">git</span> merge <span style="color: #660033;">-s</span> subtree master</pre></div></div>

<p>Finally, I can commit my changes to SVN in one squashed commit:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">git</span> <span style="color: #c20cb9; font-weight: bold;">svn</span> dcommit</pre></div></div>

<p>I&#8217;ve also found that using <code>git svn rebase</code> causes separate commits to be made instead of getting a squashed commit, but the cases I&#8217;ve run into are pretty simple so far.</p>
<p>So that&#8217;s how I brought my GitHub project into an SVN repository. Hopefully this will help somebody else who might run into the same situation.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.liveandcode.com/2009/05/27/from-git-to-svn/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

