<?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>Conceptric &#187; git</title>
	<atom:link href="http://www.conceptric.co.uk/tag/git/feed" rel="self" type="application/rss+xml" />
	<link>http://www.conceptric.co.uk</link>
	<description>Ideas and Applications</description>
	<lastBuildDate>Fri, 12 Aug 2011 13:00:25 +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>Working with Git and Subversion</title>
		<link>http://www.conceptric.co.uk/working-with-git-and-subversion.htm</link>
		<comments>http://www.conceptric.co.uk/working-with-git-and-subversion.htm#comments</comments>
		<pubDate>Wed, 10 Jun 2009 11:58:35 +0000</pubDate>
		<dc:creator>James Whinfrey</dc:creator>
				<category><![CDATA[Computing]]></category>
		<category><![CDATA[Software Engineering]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[processes]]></category>
		<category><![CDATA[subversion]]></category>
		<category><![CDATA[version control]]></category>

		<guid isPermaLink="false">http://www.conceptric.co.uk/?p=191</guid>
		<description><![CDATA[I've got a local copy of the Subversion repository under Git, so I thought I should talk about my workflow.]]></description>
			<content:encoded><![CDATA[<p>Last time I <a href="http://www.conceptric.co.uk/importing-a-remote-subversion-repository-with-git.htm">created a local Git repository</a>, in which I could have several <code>svn/</code> prefixed branches and one <code>master</code> which is linked to the remote <code>trunk</code>.</p>

<h3>The Git work environment.</h3>

<p>Working with Git is quite different to using Subversion. The actual contents of the project directory change to reflect the currently active branch: the directory contains a whole repository, not a checked out copy. Don&#8217;t get alarmed when files start disappearing only to reappear again when you switch branch.</p>

<p>I also noticed that I interacted with the version control less frequently when editing, delete, and create files. The interaction is saved until you&#8217;re ready to commit, making the process feel more seamless. I occasionally used to get into trouble by deleting files via the <abbr title="Operating System">OS</abbr>, rather that using the Subversion command.</p>

<p>For the majority of the time, I&#8217;ll use the <a href="http://www.kernel.org/pub/software/scm/git/docs/">Git commands</a>, as I&#8217;m working in a Git repository. The <code>git svn</code> functionality is only needed as a Git interface with Subversion.</p>

<h3>Getting ready to work.</h3>

<p>I like the <code>master</code> branch to always reflects the current <code>trunk</code> until I choose to update it, so all my commits are made from other working branches.</p>

<p>I start by checking out a branch based on <code>master</code> to use as a base from which to work. I&#8217;ve imaginatively called it <code>basework</code> in this example, and as a branch of <code>master</code> it is linked to the same remote branch: <code>trunk</code>.</p>

<p><code class="terminal oddlines">git branch -a</code></p>

<p>should display all your branches in the repository.</p>

<p><samp class="stdout">jkw@mac> git branch -a
* basework
  master
  svn/trunk
jkw@mac>
</samp></p>

<p>I work in increments based on stories, that&#8217;s another post, so I actually create a story branch from <code>basework</code>, that can be merge back into this parent upon completing the story. This helps cope with changes in the remote codebase.</p>

<h3>Creating my working branches.</h3>

<p>It&#8217;s a good idea to check that <code>basework</code> is up to date with the remote Subversion <code>trunk</code> before branching:</p>

<p><code class="terminal oddlines">git svn rebase</code></p>

<p>This will either update the local repository with the remote changes, or tell you that the current branch is already up to date.</p>

<p>I&#8217;m now in a position to create my story branch:</p>

<p><code class="terminal oddlines">git checkout -b inwork</code></p>

<p>The <code>-b</code> option is used to create a new branch and then switch to it. Without this option the same command is used to move between branches.</p>

<p>This same process was used to create <code>basework</code>.</p>

<p>I have my working repository structure, and I&#8217;m currently working on my story branch, see the asterisk.</p>

<p><samp class="stdout">jkw@mac> git branch -a
  basework
* inwork
  master
  svn/trunk
jkw@mac>
</samp></p>

<h3>The local commit.</h3>

<p>You can see details of the changes to the local working branch using the <code>git status</code> command:</p>

<p><samp class="stdout">jkw@mac> git status</p>

<h1>On branch inwork</h1>

<p>nothing to commit (working directory clean)
james@cybermac1> git st</p>

<h1>On branch inwork</h1>

<h1>Changed but not updated:</h1>

<h1>(use &#8220;git add/rm <file>&#8230;&#8221; to update what will be committed)</h1>

<h1>(use &#8220;git checkout &#8212; <file>&#8230;&#8221; to discard changes in working directory)</h1>

<p>#</p>

<h1>modified:   footer.php</h1>

<h1>deleted:    images/feed-icon-64.png</h1>

<h1>modified:   style.css</h1>

<p>#</p>

<h1>Untracked files:</h1>

<h1>(use &#8220;git add <file>&#8230;&#8221; to include in what will be committed)</h1>

<p>#</p>

<h1>includes/category-1.inc.php</h1>

<p>no changes added to commit (use &#8220;git add&#8221; and/or &#8220;git commit -a&#8221;)
jkw@mac> 
</samp></p>

<p>To add the new file show in the example to those being tracked:</p>

<p><code class="terminal oddlines">git add includes/category-1.inc.php</code></p>

<p>If I wanted to add all of the untracked files, I could use the <code>-A</code> option instead of individually naming them.</p>

<p>Now all the files are staged, the time comes to commit them to the local Git repository:</p>

<p><code class="terminal oddlines">git commit -a <em>-m "A message to describe the changes."</em></code></p>

<p>Leaving the <code>-m</code> option off will cause Git to request comments using whichever editor is defined in your configuration files.</p>

<p>I now the story is complete, and all the changes committed to the <code>inwork</code> branch, it&#8217;s time to commit them to Subversion.</p>

<h3>The remote commit.</h3>

<p>I start the remote commit process by switching to the <code>basework</code> branch:</p>

<p><code class="terminal oddlines">git checkout basework</code></p>

<p>Next I check that the remote codebase hasn&#8217;t changed, or update the changes:</p>

<p><code class="terminal oddlines">git svn rebase</code></p>

<p>I&#8217;ll merge <code>inwork</code> into <code>basework</code>:</p>

<p><code class="terminal oddlines">git merge inwork</code></p>

<p>I use my text editor to manually fix conflicts that arise. Git tells you where to find them by marking up the code. This is followed by another local commit, at which point the merge is complete.</p>

<p>Now I can try a dry run of the remote commit:</p>

<p><code class="terminal oddlines">git svn dcommit -n</code></p>

<p>It&#8217;s the <code>-n</code> option that makes this a dry run: nothing has been committed yet. It shows you the local versions to be bulk committed if you choose to go ahead. To actually perform the commit, remove the <code>-n</code>, and re-run the command, it may take a while if you&#8217;ve been busy.</p>

<h3>Verifying the remote commit.</h3>

<p>This is where leaving the <code>master</code> branch untouched pays off. <code>basework</code> has been committed to the remote <code>trunk</code>, whilst <code>master</code> still reflects the pre-commit <code>trunk</code>.</p>

<p>I switch to <code>master</code>, which should contain none of my new work, and update it from the remote <code>trunk</code>:</p>

<p><code class="terminal oddlines">git svn rebase</code></p>

<p>It should have changed to match <code>basework</code>, and if so the previous commit worked.</p>

<h3>Cleaning up.</h3>

<p>I&#8217;ve verified the commit: I have <code>master</code> and <code>basework</code> branches that are identical, so <code>inwork</code> is no longer needed, I&#8217;ll delete it:</p>

<p><code class="terminal oddlines">git branch -d inwork</code></p>

<p>Deleting a child branch of a different parent is a little dangerous, so if you&#8217;re not in <code>basework</code> you&#8217;ll get a warning. Either switch to <code>basework</code> and try again, or re-running the command with the <code>-D</code> option.</p>

<p>If I&#8217;ve finished work on this project, I&#8217;d delete the <code>basework</code> branch too, but if I&#8217;m going to continue, I&#8217;d use it to create another working branch, and I&#8217;ve gone full circle.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.conceptric.co.uk/working-with-git-and-subversion.htm/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Importing a remote Subversion repository with Git</title>
		<link>http://www.conceptric.co.uk/importing-a-remote-subversion-repository-with-git.htm</link>
		<comments>http://www.conceptric.co.uk/importing-a-remote-subversion-repository-with-git.htm#comments</comments>
		<pubDate>Thu, 04 Jun 2009 12:02:38 +0000</pubDate>
		<dc:creator>James Whinfrey</dc:creator>
				<category><![CDATA[Computing]]></category>
		<category><![CDATA[Everything]]></category>
		<category><![CDATA[Posts]]></category>
		<category><![CDATA[Software Engineering]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[git svn]]></category>
		<category><![CDATA[subversion]]></category>
		<category><![CDATA[version control]]></category>

		<guid isPermaLink="false">http://www.conceptric.co.uk/?p=189</guid>
		<description><![CDATA[To start this series about teaming Git with Subversion, I need to create a local copy of the Subversion Repository.]]></description>
			<content:encoded><![CDATA[<p>Lets get the obvious stuff over with, create a directory in which to initialise the local git repository.</p>

<p><code class="terminal">mkdir myproject
cd myproject
</code></p>

<p>The initialisation itself is pretty simple, just remember to point Git at the correct url for your Subversion repository, and watch the communication protocols.</p>

<p><code class="terminal oddlines">git svn init -s --prefix=svn/ svn+ssh://svn.repository.com/svn/<em>myproject</em></code></p>

<p>The <code>-s</code> option tells the repository to expect the typical trunk, branches and tags structure of a Subversion project. You can specify the location of your trunk, branches and tags using the <code>-T</code>, <code>-b</code>, and <code>-t</code> respectively.</p>

<p>Using the <code>--prefix</code> option is handy, ensuring that the remote directories will be prefixed with <code>svn/</code>. This makes it clear which are Subversion and which git branches later.</p>

<p>All that remains is to checkout all of the information relating to your project from the Subversion repository.</p>

<p><code class="terminal oddlines">git svn fetch</code></p>

<p>Depending on the size of the project, this could take a while, it&#8217;s downloading the entire project history from the remote repository.</p>

<p>I word of warning you about the strangeness that can ensue if the remote repository contains any tags. They will be imported as git branches, and you may find the local master branch pointing to something other that the remote <code>trunk</code>.</p>

<p>These <a href="http://www.kernel.org/pub/software/scm/git/docs/git-svn.html"><code>git svn</code> commands</a>, and all the others, are pretty well documented. Now I&#8217;ve got a Git repository, in the next post I&#8217;ll to describe my normal workflow.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.conceptric.co.uk/importing-a-remote-subversion-repository-with-git.htm/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Advantages of a Git and Subversion blend</title>
		<link>http://www.conceptric.co.uk/advantages-of-a-git-and-subversion-blend.htm</link>
		<comments>http://www.conceptric.co.uk/advantages-of-a-git-and-subversion-blend.htm#comments</comments>
		<pubDate>Sat, 30 May 2009 19:48:23 +0000</pubDate>
		<dc:creator>James Whinfrey</dc:creator>
				<category><![CDATA[Computing]]></category>
		<category><![CDATA[Everything]]></category>
		<category><![CDATA[Posts]]></category>
		<category><![CDATA[Software Engineering]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[git svn]]></category>
		<category><![CDATA[subversion]]></category>
		<category><![CDATA[version control]]></category>

		<guid isPermaLink="false">http://www.conceptric.co.uk/?p=187</guid>
		<description><![CDATA[I've had time to try Git with my remote Subversion repositories, using the <code>git svn</code> commands, and I wouldn't go back. To start this small series, I'll try to explain the enthusiasm.]]></description>
			<content:encoded><![CDATA[<p>Using <a href="http://git-scm.com/">Git</a> as a front-end to Subversion provides more comprehensive version control and flexibility in the way I work, especially for a laptop user. Everything is under active version control, with or without a connection to the remote Subversion repository.</p>

<p>Branching and merging is quick and simple, and as a result I find I do this far more often than when using Subversion alone. I also commit changes more frequently: it&#8217;s far quicker than using a remote repository, even when not off-line.</p>

<p>This sort of functionality is vital to successful version control, and I think it promotes better practice, as long as you&#8217;re only committing working software. All the local Git commits will later be bulk committed to the remote repository. However they all retain their identity as separate versions, so discipline is important, we wouldn&#8217;t want anyone finding broken code.</p>

<p>I could get all this from Git alone, but the combination retains Subversion vendor branching and the deployment advantages of my existing Subversion / Capistrano set up. I&#8217;m going to try <a href="http://github.com/">GitHub</a>, or my own remote Git repository, and exploiting the Capistrano support for Git, but at the moment why reinvent the wheel?</p>

<p>I prefer to work on the command line, and that&#8217;s the approach this series will take, but <a href="http://quiteuseful.co.uk/post/97148287/git-guis">GUIs are available for Git</a>, try typing <a href="http://www.kernel.org/pub/software/scm/git/docs/git-gui.html"><code>git gui</code></a> to check out the one bundled.</p>

<p>I use this approach for anything I need version controlled, including my Curriculum vitae/Resume, but before try this out for yourself you&#8217;re going to need to check out a local copy of that remote Subversion repository&#8230; I&#8217;ll cover that next time.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.conceptric.co.uk/advantages-of-a-git-and-subversion-blend.htm/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What Git does best.</title>
		<link>http://www.conceptric.co.uk/what-git-does-best.htm</link>
		<comments>http://www.conceptric.co.uk/what-git-does-best.htm#comments</comments>
		<pubDate>Tue, 18 Nov 2008 20:55:40 +0000</pubDate>
		<dc:creator>James Whinfrey</dc:creator>
				<category><![CDATA[Computing]]></category>
		<category><![CDATA[Everything]]></category>
		<category><![CDATA[Posts]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Software Engineering]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[version control]]></category>

		<guid isPermaLink="false">http://www.conceptric.co.uk/?p=122</guid>
		<description><![CDATA[I've succumbed to the lure of the cool kids version control. GIT has advantages and disadvantage over my current favourite, Subversion.]]></description>
			<content:encoded><![CDATA[<p>I run several remote Subversion repositories and connect using SSH over the Internet. Having local version control for those times I don&#8217;t have an ADSL connection was the main reason I looked at Git.</p>

<p>There&#8217;s a good <a href="http://blog.macromates.com/2008/git-bundle/">TextMate bundle to support Git</a>, but to be honest I&#8217;ve mostly used the command-line.</p>

<h3>Weaknesses.</h3>

<p><a href="http://svnbook.red-bean.com/en/1.0/ch07s04.html">Vendor branching</a> is possible, <a href="http://sourceware.org/frysk/build/git-fu.html">but awkward</a>. I frequently use vendor drops of WordPress, SimpleTest and a number of other libraries. There may be a good way of doing this, but I haven&#8217;t found it online&#8230; yet.</p>

<p>I miss the <a href="http://svnbook.red-bean.com/en/1.0/ch07s03.html">svn:externals</a> functionality, especially in applications that use a lot of plugins: WordPress in particular. Subversion allows me to define particular tagged versions of these to be pulled from their repositories during deployment without needing to bother controlling them myself.</p>

<h3>Strengths.</h3>

<p>Branch merging when trying out new ideas is a dream. I created a new branch, refactored huge sections of the codebase, and merged it all back together flawlessly. With Subversion this would have been a lot slower and more problematic. Git&#8217;s simply great for those investigatory spikes.</p>

<h3>The verdict for Git.</h3>

<p>I&#8217;ve yet to seriously try Git to interface with my remote Subversion repositories, using the &#8216;git svn&#8217; series of commands. Having local copies of these, whilst still being able to use remote Subversion would be very useful. I&#8217;ve found using remote Subversion repositories easy, but trying to push a Git repository to Subversion is not so easy. I&#8217;m also going to try deploying from a Git repository using Capistrano in the near future.</p>

<p>It strikes me that Git is best at programmer related activities and weakest in those of interest to administrators deploying applications. I shall certainly continue to use it, but alongside Subversion.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.conceptric.co.uk/what-git-does-best.htm/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

