<?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>gitguru &#187; workflow</title>
	<atom:link href="http://gitguru.com/category/workflow/feed/" rel="self" type="application/rss+xml" />
	<link>http://gitguru.com</link>
	<description>meditations on scm using git</description>
	<lastBuildDate>Wed, 25 Mar 2009 04:32:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Branching Strategies in Git &#8211; Overview</title>
		<link>http://gitguru.com/2009/02/18/branching-strategies-overview/</link>
		<comments>http://gitguru.com/2009/02/18/branching-strategies-overview/#comments</comments>
		<pubDate>Wed, 18 Feb 2009 18:00:58 +0000</pubDate>
		<dc:creator>long</dc:creator>
				<category><![CDATA[workflow]]></category>
		<category><![CDATA[branches]]></category>
		<category><![CDATA[lifecycle]]></category>
		<category><![CDATA[team]]></category>

		<guid isPermaLink="false">http://gitguru.com/?p=73</guid>
		<description><![CDATA[Creating a branch in Git is simple: $ git branch new_branch That&#8217;s all that&#8217;s absolutely required (see the man page for all the options).  And with that you now have a new branch to work on whose starting point is where you just were in your Git repository. So what can you do with it? [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: left;">Creating a branch in Git is simple:</p>
<p style="text-align: left; padding-left: 30px;"><code>$ git branch <em>new_branch</em></code></p>
<p style="text-align: left;">That&#8217;s all that&#8217;s absolutely required (see <a href="http://www.kernel.org/pub/software/scm/git/docs/git-branch.html">the man page</a> for all the options).  And with that you now have a new branch to work on whose starting point is where you just were in your Git repository.</p>
<p style="text-align: left;">So what can you do with it? Or more to the point, what should you do with it?<strong></strong></p>
<p style="text-align: left;"><strong>For a single developer</strong>, you can work on an experimental code path: You&#8217;ve got an idea about how a feature should be implemented and want to get started.  But you&#8217;ve also got some regular development that needs to take place at the same time (fixes, other features, etc.).  So create a branch and code away:</p>
<p style="text-align: left; padding-left: 30px;"><code>$ git branch feature_x dev<br />
$ git checkout feature_x<br />
# add/commit... add/commit... add/commit</code>
</p>
<p style="text-align: center;"><img class="size-full wp-image-81" title="Feature branch created off dev branch" src="http://gitguru.com/wp-content/uploads/2009/02/sd_branch.png" alt="Feature branch created off dev branch" width="500" height="175" /></p>
<p style="text-align: left;">If the feature code works out, you merge it back into your development branch.</p>
<p style="padding-left: 30px; text-align: left;"><code>$ git checkout dev<br />
$ git merge feature_x<br />
</code>
</p>
<p style="text-align: center;"><img class="alignnone size-full wp-image-95" title="Feature branch merged into dev branch" src="http://gitguru.com/wp-content/uploads/2009/02/sd_merge.png" alt="Feature branch merged into dev branch" width="500" height="175" /></p>
<p style="text-align: left;">If not, you just go back to the dev branch and delete feature_x:</p>
<p style="text-align: left; padding-left: 30px;"><code>$ git checkout dev<br />
$ git branch -D feature_x</code>
</p>
<p style="text-align: center;"><img class="size-full wp-image-120 aligncenter" title="Feature branch left unmerged" src="http://gitguru.com/wp-content/uploads/2009/02/sd_no_merge.png" alt="Feature branch left unmerged" width="500" height="175" /></p>
<p style="text-align: left;">Actually, you really don&#8217;t have to delete the branch.  You can leave it as is in case you want to easily go back to take a look at that work.</p>
<p style="text-align: left;"><strong>For a team</strong>, branches separate each developer&#8217;s individual updates.  The distributed nature of Git sets up a default branch structure: Each repository creates a new branch in the extended repository network.</p>
<p style="text-align: left;">For a set of repositories configured as</p>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-123" title="Team repositories" src="http://gitguru.com/wp-content/uploads/2009/02/team_repositories.png" alt="Team repositories" width="500" height="275" /></p>
<p style="text-align: left;">the extended branch structure would look like</p>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-124" title="Team branches" src="http://gitguru.com/wp-content/uploads/2009/02/team_branches.png" alt="Team branches" width="500" height="300" /></p>
<p style="text-align: left;">From your local repository, you&#8217;ll be limited to seeing only the branches on the remotes you&#8217;re connected to.</p>
<p style="text-align: left;">For Alice who&#8217;s connected to shared and Bob, the branches that her repository knows about are</p>
<p style="text-align: left; padding-left: 30px;"><code>alpha:alice $ git branch -a</code><code><br />
dev<br />
bob/dev<br />
shared/dev</code>
</p>
<p style="text-align: left;">For Bob who&#8217;s connected to shared and Alice,</p>
<p style="text-align: left; padding-left: 30px;"><code>beta:bob $ git branch -a</code><code><br />
dev<br />
alice/dev<br />
shared/dev</code>
</p>
<p style="text-align: left;">And for Chris,</p>
<p style="text-align: left; padding-left: 30px;"><code>gamma:chris $ git branch -a<br />
dev<br />
shared/dev<br />
</code>
</p>
<p style="text-align: left;"><strong>For a project</strong>, a branch could represent a new feature set or version of an application.  Updates are pushed up to an &#8220;integration&#8221; branch by developers as they are completed.  This is similar to the use of branching by a single developer but on a more formalized, process-driven basis.</p>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-127" title="Project integration" src="http://gitguru.com/wp-content/uploads/2009/02/prj_integration.png" alt="Project integration" width="500" height="300" /></p>
<p style="text-align: left;">In this case, Alice has already merged her changes for Project A into the shared integration branch.  Bob and Chris are still working on their changes and will need to pull in the updates before they&#8217;ll be able to push up to shared/integration.</p>
<p style="text-align: left;">Branches can also be used to represent the application&#8217;s lifecycle, with separate branches for each state such as development, test, and production.</p>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-128" title="Lifecycle via branches" src="http://gitguru.com/wp-content/uploads/2009/02/lifecycle.png" alt="Lifecycle via branches" width="600" height="200" /></p>
<p style="text-align: left;">This is the ideal case where changes flow from development to test and then from test to production.</p>
<p style="text-align: left;">These strategies are, of course, only a starting point.  Your actual branching structure will depend on your team and where you are in your application development cycle.  And odds are it&#8217;ll evolve along the way.</p>
<p style="text-align: left;">We&#8217;ll be going into more detail in future posts.</p>
]]></content:encoded>
			<wfw:commentRss>http://gitguru.com/2009/02/18/branching-strategies-overview/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
