<?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; git</title>
	<atom:link href="http://gitguru.com/tag/git/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>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Rebase v Merge in Git</title>
		<link>http://gitguru.com/2009/02/03/rebase-v-merge-in-git/</link>
		<comments>http://gitguru.com/2009/02/03/rebase-v-merge-in-git/#comments</comments>
		<pubDate>Tue, 03 Feb 2009 20:04:56 +0000</pubDate>
		<dc:creator>long</dc:creator>
				<category><![CDATA[commands]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[merge]]></category>
		<category><![CDATA[rebase]]></category>

		<guid isPermaLink="false">http://gitguru.com/?p=22</guid>
		<description><![CDATA[If you haven&#8217;t worked with a version control tool that allows for easy branching, you&#8217;re probably wondering what the difference is between rebase and merge and why you&#8217;d choose one over the other.
From the standpoint of the end result, a merge and a rebase in Git appear to do the same thing:
A + B + [...]]]></description>
			<content:encoded><![CDATA[<p>If you haven&#8217;t worked with a version control tool that allows for easy branching, you&#8217;re probably wondering what the difference is between rebase and merge and why you&#8217;d choose one over the other.</p>
<p>From the standpoint of the end result, a <a href="http://www.kernel.org/pub/software/scm/git/docs/git-merge.html">merge</a> and a <a href="http://www.kernel.org/pub/software/scm/git/docs/git-rebase.html">rebase</a> in Git appear to do the same thing:</p>
<p style="padding-left: 30px;"><strong>A</strong> + <strong>B</strong> + <strong>A&#8217;</strong> (merge) = <strong>A</strong> + <strong>A&#8217;</strong> + <strong>B</strong> (rebase)</p>
<p>Wouldn&#8217;t it be simpler to just choose one operation and stick with it?</p>
<p>The answer of course is no.  Otherwise you wouldn&#8217;t have the option.  (If you feel completely contrary, best of luck.  And choose merge.)</p>
<p>It really only becomes apparent once your development effort becomes hierarchical, either in terms of application lifecycle (such as dev, test and release versions) or in a team structure.  You&#8217;re now dealing with multiple branches, each with non-trivial changes that can and will occur independently.</p>
<p>Rebases are how changes should pass from the top of hierarchy downwards and merges are how they flow back upwards.</p>
<p>Let&#8217;s take a look in more detail at what is actually taking place in each operation for a parent branch <strong>A</strong> and a child branch <strong>B</strong>:</p>
<p style="padding-left: 30px;"><span style="text-decoration: underline;">Merge</span><strong></strong></p>
<p style="padding-left: 30px;"><strong>A</strong> + <strong>B</strong> + <strong>A&#8217;</strong> + <strong>dA&#8217;B</strong></p>
<p style="padding-left: 30px;">where <strong>A&#8217;</strong> are the changes being merged in and <strong>dA&#8217;B</strong> the resolution of merge conflicts from <strong>A&#8217;</strong> and the set of commits <strong>B</strong> on the current branch</p>
<p style="padding-left: 30px;">The changes introduced by <strong>A&#8217;</strong> and <strong>dA&#8217;B</strong> are grouped together into one merge commit <strong>A&#8221;</strong> = <strong>A&#8217;</strong> + <strong>dA&#8217;B</strong> that is added on top of the existing set of commits (<strong>A</strong> + <strong>B</strong>) and becomes the head of the current branch:</p>
<p style="padding-left: 30px;"><strong>A</strong> + <strong>B</strong> + <strong>A&#8221;</strong></p>
<p style="padding-left: 30px;"><strong></strong><span style="text-decoration: underline;">Rebase</span></p>
<p style="padding-left: 30px;"><strong>A</strong> + <strong>A&#8217;</strong> + <strong>B</strong> + <strong>dA&#8217;B</strong></p>
<p style="padding-left: 30px;">The rebase resets the starting point the branch and reapplies the set of commits <strong>B</strong>.  Merge conflicts <strong>dA&#8217;B</strong> are combined with these commits so they become grouped together <strong>B&#8217;</strong> = <strong>B</strong> + <strong>dA&#8217;B</strong>:</p>
<p style="padding-left: 30px;"><strong>A</strong> + <strong>A&#8217;</strong> + <strong>B&#8217;</strong></p>
<p>If you stare at it, you&#8217;ll realize that the rebase guarantees that the changes being brought it in from the other branch come in exactly as-is: <strong>A</strong> + <strong>A&#8217;</strong>.  Any conflicts are resolved and contained with the associated commits <strong>B&#8217;</strong> on the current branch.</p>
<p>Using merge to pull in changes from the higher-level branch mixes those changes with the resolved merge conflicts.  This means that the current branch won&#8217;t necessarily have the same state as the one it was based on (from the hierarchical structure).  And since the resolved conflicts are grouped all together in one merge commit, you&#8217;ve also made it harder to cleanly cherry-pick individual changes.</p>
<p>Having development lifecycle tracks and each local developer branch start from known consistent states is critical to reducing and resolving code issues.  Where a change occurs (or suddenly becomes missing) and who is responsible become easier to determine.  By using the rebase to pull in changes, you have that.</p>
<p>When you&#8217;re submitting changes back up the chain, you only want to add your changes on top of the existing commits of the higher-level branch.  Merge is clearly the operation for that.</p>
<p>Even if you&#8217;re a single developer with only a few branches, it&#8217;s worth it to get in the habit of using rebase and merge properly.  The basic work pattern will look like:</p>
<ol>
<li>Create new branch <strong>B</strong> from existing branch <strong>A</strong></li>
<li>Add/commit changes on branch <strong>B</strong></li>
<li>Rebase updates from branch <strong>A</strong></li>
<li>Merge changes from branch <strong>B</strong> onto branch <strong>A</strong></li>
</ol>
<p><strong><br />
</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://gitguru.com/2009/02/03/rebase-v-merge-in-git/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Git is just a tool</title>
		<link>http://gitguru.com/2009/01/29/git-is-just-a-tool/</link>
		<comments>http://gitguru.com/2009/01/29/git-is-just-a-tool/#comments</comments>
		<pubDate>Fri, 30 Jan 2009 07:15:20 +0000</pubDate>
		<dc:creator>long</dc:creator>
				<category><![CDATA[git]]></category>
		<category><![CDATA[scm]]></category>

		<guid isPermaLink="false">http://gitguru.com/?p=3</guid>
		<description><![CDATA[Repeat after me: Git is just a tool.
That&#8217;s not a bad thing.  It simply means that it&#8217;s not any more or any less than what it claims to be: a distributed version control system.  And it&#8217;s very good at what it does.
But once you get beyond the initial repository setup and the standard add/commit cycle, [...]]]></description>
			<content:encoded><![CDATA[<p>Repeat after me: <a href="http://git-scm.com/">Git</a> is just a tool.</p>
<p>That&#8217;s not a bad thing.  It simply means that it&#8217;s not any more or any less than what it claims to be: a distributed version control system.  And it&#8217;s very good at what it does.</p>
<p>But once you get beyond the initial repository setup and the standard add/commit cycle, you&#8217;re inevitably going to have a few questions:</p>
<ul>
<li> How often should I commit my changes?</li>
<li> When should I create a new branch?</li>
<li> What do I need to do to share my updates?</li>
</ul>
<p>And these lead to a few more</p>
<ul>
<li> How do I manage all these branches?</li>
<li> When should I merge the changes from my branches together?</li>
<li> What&#8217;s the difference between a merge and rebase?</li>
</ul>
<p>If you&#8217;re working in a team, you&#8217;ll probably also have</p>
<ul>
<li> What&#8217;s everyone working on?</li>
<li> Do I have the latest updates?</li>
<li> When do I submit my changes to the team?</li>
</ul>
<p>And if you&#8217;ve been going for a while, you&#8217;ll want to know</p>
<ul>
<li>How do I simultaneously manage a release and a development version?</li>
<li>Did that production fix get back into development?</li>
<li>What did I just release?</li>
</ul>
<p>At this point, you&#8217;re starting to slip into the realm of <a href="http://en.wikipedia.org/wiki/Software_configuration_management">software configuration management (SCM)</a>.  Version control is just a small part of that.</p>
<p>The bad news is that Git doesn&#8217;t say anything about how you should do any of this (FYI, the <a href="http://github.com/guides/pull-requests">pull request</a> is more a suggestion than a formal required process even if it&#8217;s what <a href="http://www.youtube.com/watch?v=4XpnKHJAok8">Linus does</a>).  It&#8217;s also the good news: You have all the technical capabilities you need but you&#8217;re not tied to a rigid one-size-fits-all process.</p>
<p>The key thing to remember is that Git isn&#8217;t the first VCS tool out there, even if it might be the first one you&#8217;re using.  There&#8217;s an amazing wealth of SCM knowledge to tap into.  It&#8217;s a matter of starting with what works and figuring out how Git fits into that.</p>
]]></content:encoded>
			<wfw:commentRss>http://gitguru.com/2009/01/29/git-is-just-a-tool/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
