<?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>the fancy part of the web &#187; version control</title>
	<atom:link href="http://blog.tolleiv.de/tag/version-control/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.tolleiv.de</link>
	<description>is elsewhere - this is just about all sorts of web related work with a small factor of fanciness</description>
	<lastBuildDate>Sat, 21 Jan 2012 12:58:05 +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>Using git svn for TYPO3 extension development</title>
		<link>http://blog.tolleiv.de/2010/06/git-svn-for-typo3-extension-development/</link>
		<comments>http://blog.tolleiv.de/2010/06/git-svn-for-typo3-extension-development/#comments</comments>
		<pubDate>Wed, 30 Jun 2010 06:00:30 +0000</pubDate>
		<dc:creator>tolleiv</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[typo3]]></category>
		<category><![CDATA[version control]]></category>

		<guid isPermaLink="false">http://blog.tolleiv.de/?p=391</guid>
		<description><![CDATA[When I first saw a presentation about Git 2 years ago I liked it, but I was convinced that Subversion covers all I need. Things have changed and especially the bad performance of Subversion for larger repositories and the need to commit things without messing up the official trunk motivated me to look up ...]]></description>
			<content:encoded><![CDATA[<p>When I first saw a presentation about Git 2 years ago I liked it, but I was convinced that Subversion covers all I need. Things have changed and especially the bad performance of Subversion for larger repositories and the need to commit things without messing up the official trunk motivated me to look up how to get started with Git. If you need more reasons why you should look into Git, you&#8217;ll find them in <a href="#git-sources">[7]</a> &#8211; anyways it&#8217;s worth to have a look how I managed to work with it <img src='http://blog.tolleiv.de/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>There are basically 2½ different tasks during the &#8220;daily&#8221; development.</p>
<ol start="0">
<li><em>Create a local working copy a.k.a clone the repository</em>
<li>Fix a bug or implement a feature and create a patch file with the changes</li>
<li>Receive a patch and review it &#8211; eventually commit the changes</li>
</ol>
<h4>0. Repository initialization</h4>
<p>Getting started and creating the repository from an existing Subversion repository looks like this:</p>
<pre name="code" class="php">mkdir templavoila
cd templavoila
git svn init -t tags -b branches -T trunk https://svn.typo3.org/TYPO3v4/Extensions/templavoila
git-svn fetch</pre>
<p>This will pull the entire SVN history into your local Git repository &#8211; use &#8220;git-svn fetch -r <revision>&#8221; to reduce the amount of imported revisions. </p>
<p>To keep your repository up-to-date you need these commands:</p>
<pre name="code" class="php">git stash
git-svn fetch
git rebase trunk
git stash apply</pre>
<p>If you followed the SVN trunk/tags/branches convention you should see that it also finds tags and branches during the import. But using &#8220;git branch&#8221; afterwards you&#8217;ll see that there&#8217;s only one local branch called &#8220;master&#8221;. That&#8217;s where Git shows it&#8217;s strength the first time, because it distinguishes between local and remote branches. Work can only be done within local branches, whereas the existing SVN branches are only recognized as &#8220;remote&#8221; branches so far. To list all remote branches you can use &#8220;git branch -r&#8221;. If you followed the trunk/tags/branches convention, you should see your SVN tags and branches within this list &#8211; otherwise you might want to read <a href="#git-sources">[8]</a>. To make a remote (SVN) branch available in your local repository use:</p>
<pre name="code" class="php">git checkout --track -b tv_1-4 templavoila_1-4</pre>
<h4>1. Working with the repository</h4>
<p>Starting to work on a new feature or a bug always starts with a new branch in git:</p>
<pre name="code" class="php">git branch issue00012345
git checkout issue00012345</pre>
<p>You&#8217;re now working in the &#8220;issue00012345&#8243; branch and all commits will just be committed to that branch. Once you made changes  you can either just commit all modifications with:</p>
<pre name="code" class="php">git commit -a</pre>
<p>or add particular files and commit only these files with:</p>
<pre name="code" class="php">git add fileA
git add fileB
git commit</pre>
<p>or with a nice pre commit preview which lets you decide which lines you want to commit:</p>
<pre name="code" class="php">git add --patch
git commit</pre>
<p><strong>Preparing the patch for the mailingslist:</strong><br />
In a pure Git workflow &#8220;git format-patch&#8221; is used to communicate patches, but due to the fact that there&#8217;s a Subversion repository involved either the old style diff / patch or a workaround needs to be used to communicate changes.<br />
Creating a patch which works for the mailinglist can basically be done using:</p>
<pre name="code" class="php">git diff --no-prefix master &gt; myPatchFile.patch</pre>
<p>An alternative workaround to create proper SVN diff files (including svn revision etc..) can be found in <a href="#git-sources">[10]</a> it&#8217;s used very straight forward:</p>
<pre name="code" class="php">git svn-diff &gt; mySvnPatchFile.patch</pre>
<h4>2. Review and commit patches</h4>
<p><strong>Reviewing the patch someone sent to the list:</strong><br />
As &#8220;usual&#8221;
<pre name="code" class="php">patch -p0 &lt; myPatchFile.patch</pre>
<p> can be used to apply patch files.</p>
<p>Once the files passed the review the changes can be committed using &#8220;<strong>git add</strong>&#8221; and &#8220;<strong>git commit</strong>&#8221; as shown before.</p>
<p><strong>Committing to Subversion:</strong><br />
Once you committed everything to your local repository you&#8217;re able to perform this command to &#8220;forward&#8221; your commits to the Subversion repository. </p>
<pre name="code" class="php">git svn dcommit</pre>
<p>Practically every single commit within git will also be reflected as a single Subversion commit. For several reason this might not always suit your situation.As a workaround you could merge all commits during the merge of your feature branches into the master branch using:</p>
<pre name="code" class="php">git merge --commit --squash issue00012345
git svn dcommit</pre>
<p>Of course I don&#8217;t recommend to do this for your regular work since have small granular commits is always better.</p>
<h4>Sources and further reading</h4>
<p><a name="git-sources"></a>[1] <a href="http://spyced.blogspot.com/2009/06/patch-oriented-development-made-sane.html">Patch-oriented development made sane with git-svn</a><br />
[2] <a href="http://utsl.gen.nz/talks/git-svn/intro.html#using">An introduction to git-svn for Subversion/SVK users and deserters</a><br />
[3] <a href="http://git-scm.org/course/svn.html">Git &#8211; SVN Crash Course</a><br />
[4] <a href="http://trac.parrot.org/parrot/wiki/git-svn-tutorial">Getting the GIT checkout</a><br />
[5] <a href="http://nathanj.github.com/gitguide/tour.html">An Illustrated Guide to Git on Windows</a><br />
[6] <a href="http://stackoverflow.com/questions/1129688/git-svn-workflow-feature-branches-and-merge">git svn workflow &#8211;<br />
feature branches and merge</a><br />
[7] <a href="http://whygitisbetterthanx.com/#any-workflow">whygitisbetterthanx.com</a><br />
[8] <a href="http://www.dmo.ca/blog/20070608113513/">Multiple branches using git-svn</a><br />
[9] <a href="http://www.viget.com/extend/effectively-using-git-with-subversion/">Effectively using Git with subversion</a><br />
[10] <a href="http://mojodna.net/2009/02/24/my-work-git-workflow.html">Git Workflow with Upstream SVN</a></p>
<h4>Notes</h4>
<ul>
<li>Don&#8217;t try to dcommit to https://svn.typo3.org/TYPO3v4/Extensions/templavoila unless you know what you&#8217;re doing &#8211; I just used it to show you that it&#8217;s even working with large history projects.</öo>
<li>For projects hosted on forge.typo3.org there might be a native git support soon &#8211; stay tuned</li>
<li>Let me know if you had problems with any of the snippets</li>
<li>Further information about the review process for the TYPO3 Core and several other TYPO3 related projects can be found on <a href="http://typo3.org/teams/core/resources/maintenance-policy/">typo3.org</a></li>
</ul>
<p class="wp-flattr-button"></p>]]></content:encoded>
			<wfw:commentRss>http://blog.tolleiv.de/2010/06/git-svn-for-typo3-extension-development/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

