<?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>threehv &#187; commits</title>
	<atom:link href="http://www.3hv.co.uk/blog/tag/commits/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.3hv.co.uk/blog</link>
	<description>precision engineering for your website</description>
	<lastBuildDate>Fri, 13 Jan 2012 16:18:18 +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>Note to self: comparing two branches in git and squashing several commits into one</title>
		<link>http://www.3hv.co.uk/blog/2009/06/02/note-to-self-comparing-two-branches-in-git-and-squashing-several-commits-into-one/</link>
		<comments>http://www.3hv.co.uk/blog/2009/06/02/note-to-self-comparing-two-branches-in-git-and-squashing-several-commits-into-one/#comments</comments>
		<pubDate>Tue, 02 Jun 2009 19:49:45 +0000</pubDate>
		<dc:creator>Rahoul Baruah</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Managing Successful Projects]]></category>
		<category><![CDATA[Ruby on Rails and Software Development]]></category>
		<category><![CDATA[branches]]></category>
		<category><![CDATA[commits]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[source control]]></category>

		<guid isPermaLink="false">http://www.3hv.co.uk/blog/?p=548</guid>
		<description><![CDATA[I always forget how to do this so I&#8217;m writing it down (especially as it&#8217;s really easy and git, as usual, makes me feel stupid as Linus is so much smarter than me). Suppose you&#8217;ve been working in branch X and you&#8217;re about to merge those changes into branch Y &#8230; work in branch X [...]]]></description>
			<content:encoded><![CDATA[<p>I always forget how to do this so I&#8217;m writing it down (especially as it&#8217;s really easy and git, as usual, makes me feel stupid as Linus is so much smarter than me).  </p>
<p>Suppose you&#8217;ve been working in branch X and you&#8217;re about to merge those changes into branch Y &#8230;</p>
<ul>
<li>work in branch X and make your commits as needed</li>
<li>switch to branch Y <code>git checkout Y</code></li>
<li>compare the differences between X and Y <code>git log Y..X</code> &#8211; the order here is important; it is merge-target..merge-source</li>
<li>merge the changes from X (merge-source) into Y (merge-target) <code>git merge X</code></li>
</ul>
<p>Even better, before doing the merge, while you are still in branch X, you can squash multiple commits into a single one.  This way, branch Y, when you examine the log, has a single entry &#8220;implemented feature X&#8221;, instead of thirty-five entries all related to feature X in some way.  </p>
<ul>
<li>examine the log <code>git log</code> or even better <code>git log --pretty=oneline</code></li>
<li>choose the commit that immediately precedes the one that starts your piece of work (probably the last one before you branched to start work on feature X)</li>
<li>start an interactive rebase session &#8211; this is git-fancy-talk for picking some commits and typing a message &#8211; <code>git rebase -i THE-COMMIT-ID-OF-THE-COMMIT-YOU-SELECTED-ABOVE</code></li>
<li>Your favourite editor (or nano) will open listing the commits for feature X &#8211; edit the word &#8220;pick&#8221; to &#8220;squash&#8221; for all except the top entry, save and exit</li>
<li>Your favourite editor will open again &#8211; again showing your commit messages &#8211; add a line <em>at the top</em> stating something like &#8220;implementation of feature X&#8221; and leave the list of individual commits on separate lines below it (adding in a Fixes #123 or whatever your issue tracker demands as the last line), save and exit</li>
<li>Now if you do a <code>git log</code> you will see a single commit with a nice &#8220;implementation of feature X&#8221; log message</li>
<li>And you&#8217;re all set to merge to your master branch without cluttering its history with a long string of commit messages</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.3hv.co.uk/blog/2009/06/02/note-to-self-comparing-two-branches-in-git-and-squashing-several-commits-into-one/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.186 seconds -->

