<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>git-fu</title>
	<atom:link href="http://gitfu.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://gitfu.wordpress.com</link>
	<description>Where programmers learn from the masters</description>
	<lastBuildDate>Tue, 02 Aug 2011 19:21:53 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='gitfu.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>git-fu</title>
		<link>http://gitfu.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://gitfu.wordpress.com/osd.xml" title="git-fu" />
	<atom:link rel='hub' href='http://gitfu.wordpress.com/?pushpress=hub'/>
		<item>
		<title>git aliases: when checkout and branch are too long to type</title>
		<link>http://gitfu.wordpress.com/2008/06/26/git-aliases-when-checkout-and-branch-are-too-long-to-type/</link>
		<comments>http://gitfu.wordpress.com/2008/06/26/git-aliases-when-checkout-and-branch-are-too-long-to-type/#comments</comments>
		<pubDate>Thu, 26 Jun 2008 20:11:37 +0000</pubDate>
		<dc:creator>xentac</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://gitfu.wordpress.com/?p=21</guid>
		<description><![CDATA[Sometimes you run commands that are a little complicated or just too long to write. Git has support for command aliases that are very easy to set up. Some people like the short form of many VCS commands: co instead of checkout, ci instead of commit, di instead of diff, etc. On the face of [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gitfu.wordpress.com&amp;blog=3324537&amp;post=21&amp;subd=gitfu&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Sometimes you run commands that are a little complicated or just too long to write.  Git has support for command aliases that are very easy to set up.<br />
<span id="more-21"></span><br />
Some people like the short form of many VCS commands: co instead of checkout, ci instead of commit, di instead of diff, etc.  On the face of it, git doesn&#8217;t support these.  Instead it offers something more powerful: configurable aliases.</p>
<p>To make <code>git ci</code> into <code>git commit</code> it&#8217;s a simple <code>git config --global alias.ci commit</code>.</p>
<p>If you want to call external programs, use an exclamation mark (<code>!</code>).  If you always find you&#8217;re running <code>gitk --left-right HEAD...MERGE_HEAD</code> to visually compare merge conflicts, execute <code>git config --global alias.gitkconflict '!gitk --left-right HEAD...MERGE_HEAD'</code>.</p>
<p>&#8220;What if I want to execute something that needs arguments?&#8221; you ask.  If you just want the arguments appended to the end of the command, then you don&#8217;t have to do anything.  The <code>git ci</code> example above works fine if you want to pass certain files to it.  If you want more complicated arguments you can specify them with <code>$&lt;variable&gt;</code> notation.</p>
<p>A more complicated example that uses external commands and arguments comes from the git alias wiki page: <code>git config alias.funcdiff '!sh -c "git show \"\$0:\$2\" | sed -n \"/^[^ \t].*\$3(/,/^}/p\" &gt; .tmp1 &amp;&amp; git show \"\$1:\$2\" | sed -n \"/^[^ \t].*\$3(/,/^}/p\" &gt; .tmp2 &amp;&amp; git diff .tmp1 .tmp2"'</code></p>
<p>When you call git funcdiff &lt;old-rev&gt; &lt;new-rev&gt; &lt;path&gt; &lt;function&gt; it will create two files (.tmp1 and .tmp2) that contain only &lt;function&gt; from &lt;path&gt; from the two different revisions and run <code>git diff</code> on them.</p>
<p>References:</p>
<ul>
<li><a href="http://www.kernel.org/pub/software/scm/git/docs/git-config.html">http://www.kernel.org/pub/software/scm/git/docs/git-config.html</a></li>
<li><a href="http://http://git.or.cz/gitwiki/Aliases">http://git.or.cz/gitwiki/Aliases</a></li>
</ul>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/gitfu.wordpress.com/21/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/gitfu.wordpress.com/21/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gitfu.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gitfu.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gitfu.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gitfu.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/gitfu.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/gitfu.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/gitfu.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/gitfu.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gitfu.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gitfu.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gitfu.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gitfu.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gitfu.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gitfu.wordpress.com/21/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gitfu.wordpress.com&amp;blog=3324537&amp;post=21&amp;subd=gitfu&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://gitfu.wordpress.com/2008/06/26/git-aliases-when-checkout-and-branch-are-too-long-to-type/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9dc2dafabd66464dbde036a551ce4c70?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">xentac</media:title>
		</media:content>
	</item>
		<item>
		<title>git mergetool: when &gt;&gt;&gt;&gt;&gt;&gt;&gt; &lt;&lt;&lt;&lt;&lt;&lt;&lt; just doesn&#8217;t cut it</title>
		<link>http://gitfu.wordpress.com/2008/06/09/git-mergetool-when-just-doesnt-cut-it/</link>
		<comments>http://gitfu.wordpress.com/2008/06/09/git-mergetool-when-just-doesnt-cut-it/#comments</comments>
		<pubDate>Mon, 09 Jun 2008 08:04:52 +0000</pubDate>
		<dc:creator>xentac</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://gitfu.wordpress.com/?p=19</guid>
		<description><![CDATA[Do you ever find it difficult figuring out complex merges? &#8220;Wait, was my change the part after the &#60;&#60;&#60;&#60;&#60;&#60;&#60; or before the &#62;&#62;&#62;&#62;&#62;&#62;&#62; ?&#8221;, &#8220;What did I do here and what did they do?&#8221;, &#8220;Oh my gawd, was this whole file modified?!?&#8221; If you find yourself asking these questions, maybe you need to use git [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gitfu.wordpress.com&amp;blog=3324537&amp;post=19&amp;subd=gitfu&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Do you ever find it difficult figuring out complex merges?  &#8220;Wait, was my change the part after the &lt;&lt;&lt;&lt;&lt;&lt;&lt; or before the &gt;&gt;&gt;&gt;&gt;&gt;&gt; ?&#8221;, &#8220;What did I do here and what did they do?&#8221;, &#8220;Oh my gawd, was this whole file modified?!?&#8221;  If you find yourself asking these questions, maybe you need to use <code>git mergetool</code>.<br />
<span id="more-19"></span><br />
Back when I used darcs, and was the integrator of our project, I used to wish I could see the diff in a tool other than just my text editor, something like kdiff3, meld, or (my personal favourite) vimdiff.</p>
<p>To tell git to use vimdiff as your mergetool run <code>git config --global merge.tool vimdiff</code>.</p>
<p>If I replay one of the git conflicting merges and run <code>git mergetool</code>, I see this:</p>
<p><a href="http://gitfu.files.wordpress.com/2008/06/git-mergetool1.png"><img src="http://gitfu.files.wordpress.com/2008/06/git-mergetool1.png?w=300&#038;h=195" alt="Example vimdiff output" width="300" height="195" class="alignnone size-medium wp-image-23" /></a></p>
<p>(To recreate this yourself, in a clone of the git repository, execute <code>git checkout -b test 7a937b2e7378699553b8f88d995f9e54e722a3c0</code> and <code>git merge b468f0ce4881bf42ffc820b1cddad67dad17fd80</code>)</p>
<p>In this case, the file as I knew it is on the left and the right section is the modifications made in the remote branch.  You want to modify and save the center panel (ie. the one with the actual filename of the file with merge conflicts).</p>
<p><code>git mergetool</code> is controlled by the command line, even if you&#8217;re using a graphical tool.  What I mean is that it displays status and sometimes prompts you in the terminal that is was run in, even if you&#8217;re using a tool like meld or kdiff3.</p>
<p>If you run <code>git mergetool</code> without specify a file, it will pick the first one in the list and not let you move on till you&#8217;ve merged it completely.  Be aware that it considers a file merged if it has been modified and the exit code of the merging program indicates that everything went well and marks the file as merged (I don&#8217;t currently know a way to unmark a merge conflicted file as merged).</p>
<p>Aside from these drawbacks, <code>git mergetool</code> makes it very simple to better visualize the differences in files when doing a manual merge.</p>
<p><code>git mergetool</code> takes two optional arguments: <code>-t</code> and a list of filenames.  <code>-t</code> lets you specify a mergetool without having to set any config options.  If you pass a list of filenames to mergetool, it will only try to merge those files (assuming they&#8217;re marked as having merge confilicts).</p>
<p>References:</p>
<ul>
<li><a href="http://www.kernel.org/pub/software/scm/git/docs/git-mergetool.html">http://www.kernel.org/pub/software/scm/git/docs/git-mergetool.html</a></li>
</ul>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/gitfu.wordpress.com/19/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/gitfu.wordpress.com/19/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gitfu.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gitfu.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gitfu.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gitfu.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/gitfu.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/gitfu.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/gitfu.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/gitfu.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gitfu.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gitfu.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gitfu.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gitfu.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gitfu.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gitfu.wordpress.com/19/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gitfu.wordpress.com&amp;blog=3324537&amp;post=19&amp;subd=gitfu&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://gitfu.wordpress.com/2008/06/09/git-mergetool-when-just-doesnt-cut-it/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9dc2dafabd66464dbde036a551ce4c70?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">xentac</media:title>
		</media:content>

		<media:content url="http://gitfu.files.wordpress.com/2008/06/git-mergetool1.png?w=300" medium="image">
			<media:title type="html">Example vimdiff output</media:title>
		</media:content>
	</item>
		<item>
		<title>The pickaxe: finding changes was never easier</title>
		<link>http://gitfu.wordpress.com/2008/06/03/the-pickaxe-finding-changes-was-never-easier/</link>
		<comments>http://gitfu.wordpress.com/2008/06/03/the-pickaxe-finding-changes-was-never-easier/#comments</comments>
		<pubDate>Tue, 03 Jun 2008 07:17:01 +0000</pubDate>
		<dc:creator>xentac</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://gitfu.wordpress.com/?p=22</guid>
		<description><![CDATA[Wouldn&#8217;t it be great if you could find all the changes to a line in your entire history? Sort of like git blame, but only for revisions that match some string. This is where git&#8217;s pickaxe functionality comes in. git log, git diff, and git format-patch all can use the pickaxe. To use the pickaxe, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gitfu.wordpress.com&amp;blog=3324537&amp;post=22&amp;subd=gitfu&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Wouldn&#8217;t it be great if you could find all the changes to a line in your entire history?  Sort of like <code>git blame</code>, but only for revisions that match some string.  This is where git&#8217;s pickaxe functionality comes in.<br />
<span id="more-22"></span><br />
<code>git log</code>, <code>git diff</code>, and <code>git format-patch</code> all can use the pickaxe.</p>
<p>To use the pickaxe, just pass the -S option.  <code>git log -Sgit-diff --pretty=oneline --abbrev-commit</code> run on the git repository outputs this:</p>
<pre>497c833... Documentation: convert "glossary" and "core-tutorial" to man pages
b27a23e... Documentation: convert tutorials to man pages
0e36f2d... git-p4: Removed git-p4 submit --direct.
2cd5dfd... Teach git-grep --name-only as synonym for -l
87f1b88... mailinfo: feed only one line to handle_filter() for QP input
fdcf39e... Include rev-list options in git-log manpage.
8b30aa5... git.el: Support for getting diffs from inside the log-edit buffer.
e25cfae... contrib: resurrect scripted git-revert.
530e741... Start preparing the API documents.
18ff365... git.el: Added a menu for git-status-mode.
cc2d6b8... don't mention index refreshing side effect in git-status docs
272bd3c... Include diff options in the git-log manpage
61fd255... gitweb: Update and improve gitweb/README file
79d3066... Consolidate command list to one.
8b014d7... git-svn: info --url [path]
e6fefa9... git-svn info: implement info command
5b98d9b... user-manual: mention "..." in "Generating diffs", etc.
c1a95fa... Documentation: customize diff-options depending on particular command
b43b0a3... git-p4: Add a helper function to parse the full git diff-tree output.
9e6c723... git-diff.txt: add section "output format" describing the diff formats
6b6012e... cvsexportcommit: fix for commits that do not have parents
0cec6db... gitweb: Fix and simplify "split patch" detection
0995520... Document additional 1.5.3.5 fixes in release notes
</pre>
<p>Because tig supports all the git options, running <code>tig -Sgit-diff</code> shows you the list of commits and lets you see the diffs by hitting enter.</p>
<p>The pickaxe can help find code that&#8217;s been deleted or moved, <code>git blame</code> won&#8217;t tell you about those lines at all.  Any time you want to find out more about a piece of code than just who touched it last, the pickaxe is a good little tool to reach for.</p>
<p>References:</p>
<ul>
<li><a href="http://www.kernel.org/pub/software/scm/git/docs/git-log.html">http://www.kernel.org/pub/software/scm/git/docs/git-log.html</a></li>
<li><a href="http://http://www.kernel.org/pub/software/scm/git/docs/git-diff.html">http://www.kernel.org/pub/software/scm/git/docs/git-diff.html</a></li>
<li><a href="http://http://www.kernel.org/pub/software/scm/git/docs/git-format-patch.html">http://www.kernel.org/pub/software/scm/git/docs/git-format-patch.html</a></li>
</ul>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/gitfu.wordpress.com/22/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/gitfu.wordpress.com/22/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gitfu.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gitfu.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gitfu.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gitfu.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/gitfu.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/gitfu.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/gitfu.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/gitfu.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gitfu.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gitfu.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gitfu.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gitfu.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gitfu.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gitfu.wordpress.com/22/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gitfu.wordpress.com&amp;blog=3324537&amp;post=22&amp;subd=gitfu&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://gitfu.wordpress.com/2008/06/03/the-pickaxe-finding-changes-was-never-easier/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9dc2dafabd66464dbde036a551ce4c70?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">xentac</media:title>
		</media:content>
	</item>
		<item>
		<title>git describe: &#8220;great, another way to refer to commits!&#8221;</title>
		<link>http://gitfu.wordpress.com/2008/05/25/git-describe-great-another-way-to-refer-to-commits/</link>
		<comments>http://gitfu.wordpress.com/2008/05/25/git-describe-great-another-way-to-refer-to-commits/#comments</comments>
		<pubDate>Sun, 25 May 2008 21:46:01 +0000</pubDate>
		<dc:creator>xentac</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://gitfu.wordpress.com/?p=18</guid>
		<description><![CDATA[Wouldn&#8217;t it be great if git had a revision number that always went up so that you could look at two of them and figure out which one was later than the other? svn, cvs, hg all have numeric commits that you can refer to, so why can&#8217;t git? It turns out that git does, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gitfu.wordpress.com&amp;blog=3324537&amp;post=18&amp;subd=gitfu&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Wouldn&#8217;t it be great if git had a revision number that always went up so that you could look at two of them and figure out which one was later than the other?  svn, cvs, hg all have numeric commits that you can refer to, so why can&#8217;t git?  It turns out that git does, it&#8217;s called <code>git describe</code>.<br />
<span id="more-18"></span><br />
At its simplest <code>git describe</code> will output something that looks similar to this: <code>v1.5.5.1-178-g1f8115b</code>.  In fact, now that I&#8217;ve given you this identifier, you could find exactly where I was in the git history when I ran <code>git describe</code>.</p>
<p>The identifier tells you that I was at the 178th commit after the v1.5.5.1 tag.  Just in case history gets rewritten and the 178th commit changes or there are multiple 178th commits, we can use the hash g1f8115b to make sure it&#8217;s the right one.</p>
<p>Using <code>git describe</code> in this way you can create identifiers that work well in places where increasing version numbers are used (development snapshots, for example), but this wouldn&#8217;t be git-fu if there wasn&#8217;t more it could do.</p>
<p>If you use the &#8211;contains option, <code>git describe</code> can tell you where a commit is relative to a future tag.  For example, the output of <code>git describe --contains HEAD~90</code> is <code>v1.5.5~7</code>.  It&#8217;s just as easy to refer to a revision after a tag as it is to refer to a revision before a tag.</p>
<p>You can also use things other than tags by using <code>git describe --all</code> which looks at any ref found in .git/refs/ (common directories in .git/refs/ are heads, remotes, and tags).  These can be less helpful in the long run because heads and remotes often change.  If you want to tell someone which commit you&#8217;re referring to without giving them an entire sha1, &#8211;all can be useful.</p>
<p>References:</p>
<ul>
<li><a href="http://www.kernel.org/pub/software/scm/git/docs/git-describe.html">http://www.kernel.org/pub/software/scm/git/docs/git-describe.html</a></li>
</ul>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/gitfu.wordpress.com/18/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/gitfu.wordpress.com/18/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gitfu.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gitfu.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gitfu.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gitfu.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/gitfu.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/gitfu.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/gitfu.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/gitfu.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gitfu.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gitfu.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gitfu.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gitfu.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gitfu.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gitfu.wordpress.com/18/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gitfu.wordpress.com&amp;blog=3324537&amp;post=18&amp;subd=gitfu&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://gitfu.wordpress.com/2008/05/25/git-describe-great-another-way-to-refer-to-commits/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9dc2dafabd66464dbde036a551ce4c70?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">xentac</media:title>
		</media:content>
	</item>
		<item>
		<title>tig: graphics for those who like text</title>
		<link>http://gitfu.wordpress.com/2008/05/19/tig-graphics-for-those-who-like-text/</link>
		<comments>http://gitfu.wordpress.com/2008/05/19/tig-graphics-for-those-who-like-text/#comments</comments>
		<pubDate>Mon, 19 May 2008 02:00:15 +0000</pubDate>
		<dc:creator>xentac</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://gitfu.wordpress.com/?p=7</guid>
		<description><![CDATA[While I really enjoy qgit for visualizing history, it is a graphical client. Sometimes you&#8217;re on a remote machine or want to look at a very complicated set of commits. In those cases, git show-branch might not be enough. Enter tig. Tig is best described as a graphical history viewer in ncurses. It lets you [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gitfu.wordpress.com&amp;blog=3324537&amp;post=7&amp;subd=gitfu&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>While I really enjoy <code>qgit</code> for visualizing history, it is a graphical client.  Sometimes you&#8217;re on a remote machine or want to look at a very complicated set of commits.  In those cases, <code>git show-branch</code> might not be enough.  Enter tig.<br />
<span id="more-7"></span><br />
Tig is best described as a graphical history viewer in ncurses.  It lets you view history using the same syntax as git log, qgit, and gitk (anything supported by <code>git rev-parse</code>).  Running <code>tig</code> in a git repository will open it in &#8220;main view&#8221;.  The lines in main view look very similar to the output of <code>git log --pretty=oneline --abbrev-commit</code>.</p>
<p><a href="http://gitfu.files.wordpress.com/2008/05/tig-mainview.png"><img src="http://gitfu.files.wordpress.com/2008/05/tig-mainview.png?w=300&#038;h=195" alt="" width="300" height="195" class="alignnone size-medium wp-image-14" /></a></p>
<p><code>tig</code> has a few command line options:</p>
<ul>
<li><code>tig show</code></li>
<li><code>tig blame</code></li>
<li><code>tig status</code></li>
</ul>
<p>All of these options act the same as their git counterparts, except they show in its coloured pager.</p>
<p>When <code>tig</code> is running, you can get help by pressing &#8216;h&#8217;.  tig&#8217;s views consist of main, diff, log, tree, blob, blame, pager, status, and stage.  Most of these views are fairly simple and I&#8217;ll leave their use as an exercise for the reader.</p>
<p>Pressing &#8216;g&#8217; in main view shows the revision graph:</p>
<p><a href="http://gitfu.files.wordpress.com/2008/05/tig-graphview.png"><img src="http://gitfu.files.wordpress.com/2008/05/tig-graphview.png?w=300&#038;h=195" alt="" width="300" height="195" class="alignnone size-medium wp-image-15" /></a></p>
<p>This is what makes <code>tig</code> as useful as other visualization tools like qgit or gitk.</p>
<p>Pressing &#8216;enter&#8217; on any of the commits in main view splits the window and shows the diff below.  Vi&#8217;s &#8216;j&#8217; and &#8216;k&#8217; keys move the diff up and down.</p>
<p><a href="http://gitfu.files.wordpress.com/2008/05/tig-maindiffsplit.png"><img src="http://gitfu.files.wordpress.com/2008/05/tig-maindiffsplit.png?w=300&#038;h=195" alt="" width="300" height="195" class="alignnone size-medium wp-image-16" /></a></p>
<p> <code>tig blame</code> can be more useful than a regular <code>git blame</code> because you can press &#8216;enter&#8217; and view the diff that made the change to that line.</p>
<p>If <code>tig</code> doesn&#8217;t support some option that works with git, you can still use <code>tig</code> to page git&#8217;s output by piping git&#8217;s output into tig.  It will still colour all the items it understands, detect commit hashes, and display diffs.</p>
<p><code>tig</code> can be really helpful when doing development on a remote machine that doesn&#8217;t have vnc or any X tools installed.</p>
<p>References:</p>
<ul>
<li><a href="http://jonas.nitro.dk/tig/">http://jonas.nitro.dk/tig/</a></li>
</ul>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/gitfu.wordpress.com/7/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/gitfu.wordpress.com/7/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gitfu.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gitfu.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gitfu.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gitfu.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/gitfu.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/gitfu.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/gitfu.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/gitfu.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gitfu.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gitfu.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gitfu.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gitfu.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gitfu.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gitfu.wordpress.com/7/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gitfu.wordpress.com&amp;blog=3324537&amp;post=7&amp;subd=gitfu&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://gitfu.wordpress.com/2008/05/19/tig-graphics-for-those-who-like-text/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9dc2dafabd66464dbde036a551ce4c70?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">xentac</media:title>
		</media:content>

		<media:content url="http://gitfu.files.wordpress.com/2008/05/tig-mainview.png?w=300" medium="image" />

		<media:content url="http://gitfu.files.wordpress.com/2008/05/tig-graphview.png?w=300" medium="image" />

		<media:content url="http://gitfu.files.wordpress.com/2008/05/tig-maindiffsplit.png?w=300" medium="image" />
	</item>
		<item>
		<title>git cherry-pick: &#8220;But I don&#8217;t want all this extra history!&#8221;</title>
		<link>http://gitfu.wordpress.com/2008/05/12/git-cherry-pick-but-i-dont-want-all-this-extra-history/</link>
		<comments>http://gitfu.wordpress.com/2008/05/12/git-cherry-pick-but-i-dont-want-all-this-extra-history/#comments</comments>
		<pubDate>Mon, 12 May 2008 00:16:02 +0000</pubDate>
		<dc:creator>xentac</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://gitfu.wordpress.com/?p=13</guid>
		<description><![CDATA[Sometimes you just want a few patches from a topic branch, not the entire thing. If a bug fix was implemented that would help everyone working out of the master branch, but the rest of the topic branch isn&#8217;t acceptable, git cherry-pick is the way to go. The basic usage for git cherry-pick is git [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gitfu.wordpress.com&amp;blog=3324537&amp;post=13&amp;subd=gitfu&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Sometimes you just want a few patches from a topic branch, not the entire thing.  If a bug fix was implemented that would help everyone working out of the master branch, but the rest of the topic branch isn&#8217;t acceptable, <code>git cherry-pick</code> is the way to go.<br />
<span id="more-13"></span><br />
The basic usage for <code>git cherry-pick</code> is <code>git cherry-pick &lt;commit&gt;</code>.  This will apply &lt;commit&gt; on top of your current branch.</p>
<p><code>git cherry-pick</code> has some useful options:</p>
<ul>
<li><code>-e|--edit</code></li>
<li><code>-x</code></li>
<li><code>-n|--no-commit</code></li>
<li><code>-m &lt;parent-number&gt;</code></li>
</ul>
<p><code>-e</code> lets you edit the commit message before the patch is commited.</p>
<p><code>-x</code> adds a note to the commit message explaining where it came from originally.  This is helpful if you&#8217;re backporting a feature or fix from one branch to another.</p>
<p><code>-n</code> applies the changes but doesn&#8217;t actually create a commit.  This can be really helpful if you&#8217;re combining multiple commits from different places (it can be simpler than using <code>git rebase</code>).</p>
<p><code>-m &lt;parent-number&gt;</code> lets you cherry pick from a merge.  If you tell <code>git cherry-pick</code> which parent is the &#8220;mainline&#8221;, it can calculate the commit&#8217;s impact (its diff) relative to the mainline and apply that as a patch against your current branch.</p>
<p>References:</p>
<ul>
<li><a href="http://www.kernel.org/pub/software/scm/git/docs/git-cherry-pick.html">http://www.kernel.org/pub/software/scm/git/docs/git-cherry-pick.html</a></li>
</ul>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/gitfu.wordpress.com/13/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/gitfu.wordpress.com/13/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gitfu.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gitfu.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gitfu.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gitfu.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/gitfu.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/gitfu.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/gitfu.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/gitfu.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gitfu.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gitfu.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gitfu.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gitfu.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gitfu.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gitfu.wordpress.com/13/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gitfu.wordpress.com&amp;blog=3324537&amp;post=13&amp;subd=gitfu&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://gitfu.wordpress.com/2008/05/12/git-cherry-pick-but-i-dont-want-all-this-extra-history/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9dc2dafabd66464dbde036a551ce4c70?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">xentac</media:title>
		</media:content>
	</item>
		<item>
		<title>git rev-parse: because version control needs more set notation</title>
		<link>http://gitfu.wordpress.com/2008/05/11/git-rev-parse-because-version-control-needs-more-set-notation/</link>
		<comments>http://gitfu.wordpress.com/2008/05/11/git-rev-parse-because-version-control-needs-more-set-notation/#comments</comments>
		<pubDate>Sun, 11 May 2008 23:44:25 +0000</pubDate>
		<dc:creator>xentac</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://gitfu.wordpress.com/?p=11</guid>
		<description><![CDATA[What if you wanted to see all the revisions since a branch was created? Or all the changes included in two or more branches? Or all the changes in one branch, that has merges from another branch, but not the merges or the other branch? All of this and more can be done with git [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gitfu.wordpress.com&amp;blog=3324537&amp;post=11&amp;subd=gitfu&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>What if you wanted to see all the revisions since a branch was created?  Or all the changes included in two or more branches?  Or all the changes in one branch, that has merges from another branch, but not the merges or the other branch?  All of this and more can be done with <code>git rev-parse</code>, which is used by just about every git command that accepts a revision list.<br />
<span id="more-11"></span><br />
I will use the diagram from the git-rev-parse man page (see the references at the bottom of this post):</p>
<pre>     G   H   I   J
      \ /     \ /
       D   E   F
        \  |  / \
         \ | /   |
          \|/    |
           B     C
            \   /
             \ /
              A
</pre>
<p>(The most recent commit in this diagram is A.  A is a merge commit between B and C.)</p>
<p>A repo with this sort of history is available here: <a href="http://xennet.org/git-rev-parse-example.tar.bz2">http://xennet.org/git-rev-parse-example.tar.bz2</a></p>
<p>Everyone knows about the J^, F^1, and I~4 notation, but they&#8217;re less likely to know about the D..B, B&#8230;C, and ^J C notations.  The former are different ways to refer to a single revision and the latter are ways to refer to ranges of revisions.</p>
<p>The r1..r2 and ^r2 r1 syntaxes are actually the same. They both mean all the commits reachable by r1 but not r2.  The second syntax is slightly more powerful because you can say things like ^D ^F B.  In our example above (D..B) those commits are E I J F B.</p>
<p>The r1&#8230;r2 syntax represents the symmetric difference.  In other words, this is all the commits in r1 and r2 but not in both r1 and r2.  This is all the commits that will be merged together if the two branches are merged.  In our example above (B&#8230;C) those commits are G H D E B C.</p>
<p>If you were an integrator and wanted to review a contributor&#8217;s branch, and that contributor, during the course of development, merged from master a couple of times, how would you be able to find the commits that were only available in the contributor&#8217;s branch (contrib) and not in master?  You could easily <code>git log --no-merges ^master contrib</code> (you need the &#8211;no-merges because the patches that merge master into contrib aren&#8217;t included in master).  Using a GUI like tig (<code>tig --no-merges ^master contrib</code>), gitk, or qgit makes it trivially simple to inspect each of the diffs before integrating.</p>
<p>References:</p>
<ul>
<li><a href="http://www.kernel.org/pub/software/scm/git/docs/git-rev-parse.html">http://www.kernel.org/pub/software/scm/git/docs/git-rev-parse.html</a></li>
<li><a href="http://git.kernel.org/?p=git/git.git;a=blob;f=Documentation/git-rev-parse.txt;h=110e7ba71f48c54cb94f35e819583826e123a8b1;hb=HEAD">http://git.kernel.org/?p=git/git.git;a=blob;f=Documentation/git-rev-parse.txt;h=110e7ba71f48c54cb94f35e819583826e123a8b1;hb=HEAD</a> . There&#8217;s a bug in the git man page and generated man page html.  The illustration, by Jon Loeliger seems only to be correct in the original git-rev-parse.txt.</li>
</ul>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/gitfu.wordpress.com/11/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/gitfu.wordpress.com/11/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gitfu.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gitfu.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gitfu.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gitfu.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/gitfu.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/gitfu.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/gitfu.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/gitfu.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gitfu.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gitfu.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gitfu.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gitfu.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gitfu.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gitfu.wordpress.com/11/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gitfu.wordpress.com&amp;blog=3324537&amp;post=11&amp;subd=gitfu&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://gitfu.wordpress.com/2008/05/11/git-rev-parse-because-version-control-needs-more-set-notation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9dc2dafabd66464dbde036a551ce4c70?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">xentac</media:title>
		</media:content>
	</item>
		<item>
		<title>git bisect: finding bugs with laser precision</title>
		<link>http://gitfu.wordpress.com/2008/04/27/git-bisect-finding-bugs-with-laser-precision/</link>
		<comments>http://gitfu.wordpress.com/2008/04/27/git-bisect-finding-bugs-with-laser-precision/#comments</comments>
		<pubDate>Sun, 27 Apr 2008 22:15:53 +0000</pubDate>
		<dc:creator>xentac</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://gitfu.wordpress.com/?p=6</guid>
		<description><![CDATA[&#8220;What? I already fixed this bug! Why is it still happening?&#8221; If you don&#8217;t have a good test suite or you don&#8217;t run it regularly, finding these sorts of regressions can be difficult. Because git makes it really easy to jump to other commits (branches or history), it is very easy to narrow down what [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gitfu.wordpress.com&amp;blog=3324537&amp;post=6&amp;subd=gitfu&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>&#8220;What?  I already fixed this bug!  Why is it still happening?&#8221;  If you don&#8217;t have a good test suite or you don&#8217;t run it regularly, finding these sorts of regressions can be difficult.  Because git makes it really easy to jump to other commits (branches or history), it is very easy to narrow down what commit(s) caused the regression.  <code>git bisect</code> helps you do that.<br />
<span id="more-6"></span><br />
I&#8217;m going to go through an example of <code>git bisect</code> to show the basics.</p>
<p>Let&#8217;s say we have history that looks something like this (from the official git repo):</p>
<pre>
8419d2e... git-format-patch --in-reply-to: accept  with angle brackets
767c98a... git-add -u: do not barf on type changes
f5de799... Remove duplicate note about removing commits with git-filter-branch
f28dd47... git-clone: improve error message if curl program is missing or not executable
568d2cd... git.el: Allow the add and remove commands to be applied to ignored files.
98acc3f... git.el: Allow selecting whether to display uptodate/unknown/ignored files.
1b65504... git.el: Keep the status buffer sorted by filename.
c32da69... hooks--update: Explicitly check for all zeros for a deleted ref.
80bffaf... git-commit: Allow partial commit of file removal.
</pre>
<p>All we know is that 8419d2e has the bug and 80bffaf works, so we run <code>git bisect start 8419d2e 80bffaf</code>.  Git&#8217;s output looks like this:</p>
<pre>
$ git bisect start 8419d2e 80bffaf
Bisecting: 2 revisions left to test after this
[f28dd4774d4723e8251817e910dbdc5507282113] git-clone: improve error message if
curl program is missing or not executable
</pre>
<p>Now we&#8217;re right in the middle of these commits.  We find that the bug existed at this point too, so we run <code>git bisect bad</code>:</p>
<pre>
$ git bisect bad
Bisecting: 0 revisions left to test after this
[c32da692de332d3c9a0b283066e3786af00f4931] hooks--update: Explicitly check for all
zeros for a deleted ref.
</pre>
<p>This commit doesn&#8217;t have the bug, so we run <code>git bisect good</code>:</p>
<pre>
$ git bisect good
f28dd4774d4723e8251817e910dbdc5507282113 is first bad commit
commit f28dd4774d4723e8251817e910dbdc5507282113
Author: Gerrit Pape
Date:   Thu Sep 13 11:36:22 2007 +0000

    git-clone: improve error message if curl program is missing or not executable
</pre>
<p>&#8230;snip&#8230;</p>
<pre>
    Signed-off-by: Gerrit Pape
    Signed-off-by: Junio C Hamano 

:100755 100755 18003ab4b39ad0a7848cc20db2f6ad55e1291264
5e582fe247892fa7dffc44556c939863c36edc35 M      git-clone.sh
</pre>
<p>Now we know the exact commit that caused the regression.</p>
<p>Sure, you could have done that with a temporary branch and <code>git reset --hard</code>, but things get a lot more complicated when merges are involved.  <code>git bisect</code> doesn&#8217;t have problems walking down branches and keeping track of which sections are good and which sections are bad.</p>
<p>There are a few other options that git bisect has that can help a lot:</p>
<ul>
<li><code>git bisect visualize</code></li>
<li><code>git bisect log</code></li>
<li><code>git bisect replay</code></li>
<li><code>git bisect run</code></li>
<li><code>git bisect skip</code></li>
</ul>
<p><code>git bisect visualize</code> opens up the range you&#8217;re analyzing in gitk which lets you see which sections you&#8217;ve discounted as good or bad.</p>
<p><code>git bisect log</code> shows you history that can be replayed by <code>git bisect replay</code>.  Our example&#8217;s log looks like this:</p>
<pre>
# bad: [8419d2ee9ba8b375186a5c1019df8dfbce610aba] git-format-patch --in-reply-to:
accept  with angle brackets
# good: [80bffaf7fbe09ef62ecb9a6ffea70ac0171b456c] git-commit: Allow partial commit
of file removal.
git-bisect start '8419d2e' '80bffaf'
# bad: [f28dd4774d4723e8251817e910dbdc5507282113] git-clone: improve error
message if curl program is missing or not executable
git-bisect bad f28dd4774d4723e8251817e910dbdc5507282113
# good: [c32da692de332d3c9a0b283066e3786af00f4931] hooks--update: Explicitly
check for all zeros for a deleted ref.
git-bisect good c32da692de332d3c9a0b283066e3786af00f4931
</pre>
<p>If you screw up bisecting, you can use <code>git bisect log</code>, <code>git bisect reset</code>, and <code>git bisect replay</code> to go back and fix your mistakes.</p>
<p>If you can write a script to automatically test your regression, you can use <code>git bisect run</code>.  Your script has to do its test and exit with a status code.  If the status code is 0, the revision is good; if the status is between 1 and 127 (but not 125), the revision is bad; if the status is anything else (exit -1 is common), the automatic bisect process will stop; if the status is 125, it means skip that revision.</p>
<p><code>git bisect skip</code> is used to tell git that you can&#8217;t test this revision.  There can be cases where git won&#8217;t know which commit caused the problem if a skipped commit makes the bisect ambiguous.</p>
<p>Most newer version control systems (especially distributed ones) support bisect features.  Subversion is the notable exception.</p>
<p>References:</p>
<ul>
<li><a href="http://www.kernel.org/pub/software/scm/git/docs/git-bisect.html">http://www.kernel.org/pub/software/scm/git/docs/git-bisect.html</a></li>
</ul>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/gitfu.wordpress.com/6/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/gitfu.wordpress.com/6/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gitfu.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gitfu.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gitfu.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gitfu.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/gitfu.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/gitfu.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/gitfu.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/gitfu.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gitfu.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gitfu.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gitfu.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gitfu.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gitfu.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gitfu.wordpress.com/6/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gitfu.wordpress.com&amp;blog=3324537&amp;post=6&amp;subd=gitfu&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://gitfu.wordpress.com/2008/04/27/git-bisect-finding-bugs-with-laser-precision/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9dc2dafabd66464dbde036a551ce4c70?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">xentac</media:title>
		</media:content>
	</item>
		<item>
		<title>git rerere: rereremember what you did last time</title>
		<link>http://gitfu.wordpress.com/2008/04/20/git-rerere-rereremember-what-you-did-last-time/</link>
		<comments>http://gitfu.wordpress.com/2008/04/20/git-rerere-rereremember-what-you-did-last-time/#comments</comments>
		<pubDate>Sun, 20 Apr 2008 22:05:13 +0000</pubDate>
		<dc:creator>xentac</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://gitfu.wordpress.com/?p=8</guid>
		<description><![CDATA[Imagine you&#8217;re an integrator (someone who takes a lot of changes from other people and merges them) and you often merge other people&#8217;s branches, resolve conflicts, and then find bugs in the branch. Wouldn&#8217;t it be great if git could remember your conflict resolutions and replay them next time you try to merge? That&#8217;s what [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gitfu.wordpress.com&amp;blog=3324537&amp;post=8&amp;subd=gitfu&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Imagine you&#8217;re an integrator (someone who takes a lot of changes from other people and merges them) and you often merge other people&#8217;s branches, resolve conflicts, and then find bugs in the branch.  Wouldn&#8217;t it be great if git could remember your conflict resolutions and replay them next time you try to merge?  That&#8217;s what git rerere is for!<br />
<span id="more-8"></span><br />
To enable git rerere for all your git repos, use <code>git config --global rerere.enabled 1</code>.  This will make a change in your ~/.gitconfig.</p>
<p>After you&#8217;ve done that, <code>git rerere</code> just basically works.  Any time you have merge conflicts, it will automatically record the original and resolved states and replay them next time you try to merge.  Any merge, rebase, or am action will use <code>git rerere</code>.</p>
<p>If you have a long-lived topic branch that you know will conflict when merged with another branch (say, master), you can do a <code>git pull origin master</code>, fix conflicts and commit, and then <code>git reset --hard HEAD^</code>.  This way you can get the benefit of merging often without the history cluttering of many &#8220;useless merges&#8221;.</p>
<p>References:</p>
<ul>
<li><a href="http://www.kernel.org/pub/software/scm/git/docs/git-rerere.html">http://www.kernel.org/pub/software/scm/git/docs/git-rerere.html</a></li>
</ul>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/gitfu.wordpress.com/8/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/gitfu.wordpress.com/8/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gitfu.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gitfu.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gitfu.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gitfu.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/gitfu.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/gitfu.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/gitfu.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/gitfu.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gitfu.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gitfu.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gitfu.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gitfu.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gitfu.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gitfu.wordpress.com/8/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gitfu.wordpress.com&amp;blog=3324537&amp;post=8&amp;subd=gitfu&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://gitfu.wordpress.com/2008/04/20/git-rerere-rereremember-what-you-did-last-time/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9dc2dafabd66464dbde036a551ce4c70?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">xentac</media:title>
		</media:content>
	</item>
		<item>
		<title>git rebase: when you want to get from here to there</title>
		<link>http://gitfu.wordpress.com/2008/04/14/git-rebase-when-you-want-to-get-from-here-to-there/</link>
		<comments>http://gitfu.wordpress.com/2008/04/14/git-rebase-when-you-want-to-get-from-here-to-there/#comments</comments>
		<pubDate>Mon, 14 Apr 2008 00:00:10 +0000</pubDate>
		<dc:creator>xentac</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://gitfu.wordpress.com/?p=9</guid>
		<description><![CDATA[What do you do when you have two commits in the past that you want to re-arrange? or combine? or completely obliterate? What about after you&#8217;ve created patches, emailed them to a maintainer, and that maintainer has accepted some of them into the official repo? What if you realize that your topic branch actually has [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gitfu.wordpress.com&amp;blog=3324537&amp;post=9&amp;subd=gitfu&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>What do you do when you have two commits in the past that you want to re-arrange? or combine? or completely obliterate?  What about after you&#8217;ve created patches, emailed them to a maintainer, and that maintainer has accepted some of them into the official repo?  What if you realize that your topic branch actually has two topics in it?  These are all jobs for <code>git rebase</code>.<br />
<span id="more-9"></span><br />
Before we can talk about these use cases, we need a way to refer to commits or ranges of commits.  There are two main ways that I use when using <code>git rebase</code>: <code>git rebase &lt;branch&gt;</code> and <code>git rebase --onto &lt;newbase&gt; &lt;beginning&gt; &lt;ending&gt;</code>.  The former says, &#8220;take all the commits in my branch that aren&#8217;t currently in &lt;branch&gt; and put them on top of &lt;branch&gt;&#8221; and the latter says, &#8220;take all the commits between &lt;beginning&gt; and &lt;ending&gt; (excluding &lt;beginning&gt; itself) and put them on top of &lt;newbase&gt;&#8221;.</p>
<p>Now, let&#8217;s go through these use cases one at a time, starting from the simplest.</p>
<p>If you&#8217;ve submitted patches to a maintainer, and all or some of them have been accepted to a project, your topic branch will no longer be the same as theirs (they could have applied them at a different point, added a signed-off tag, or many other things).  To reconcile a topic branch with what&#8217;s in the current (remote) master branch, you could run <code>git rebase origin/master</code> from your topic branch.  All the patches that match up exactly with patches in <code>origin/master</code> will disappear and all patches that were edited or not included will be created on top of <code>origin/master</code>.  The topic branch you were in will then point to the newly created commits and the old commits will be relegated to the <a href="http://http://gitfu.wordpress.com/2008/04/06/git-reflog-no-commits-left-behind/">reflog</a>.</p>
<p>If you realize that your topic branch actually has two totally separate topics in it, you can use the &#8211;onto option.  A diagram helps to describe this better (diagram blatantly taken from <code>git rebase</code> man page):</p>
<pre>                        H---I---J topicB
                       /
              E---F---G  topicA
             /
A---B---C---D  master
</pre>
<p>If you want to make topicA and topicB separate branches that both branch off of master, you would run <code>git rebase --onto master topicA topicB</code>.  After running it, your repository would look like this:</p>
<pre>             H'--I'--J'  topicB
            /
            | E---F---G  topicA
            |/
A---B---C---D  master
</pre>
<p>H&#8217;, I&#8217;, and J&#8217; have the same contents as H, I, and J respectively but have different commit hashes because they have different parents.</p>
<p>If you want to change the order or contents of any commits in the past, <code>git rebase -i</code> is your friend.  If you run something like <code>git rebase -i HEAD~3</code> you will be dropped into an editor with lines something like this:</p>
<pre>
pick 428c9da Fix bugaboo
pick 503ffbe Some other patch
pick de6b9c5 Even another one

# Rebase fc08684..742098a onto fc08684
#
# Commands:
#  pick = use commit
#  edit = use commit, but stop for amending
#  squash = use commit, but meld into previous commit
#
# If you remove a line here THAT COMMIT WILL BE LOST.
# However, if you remove everything, the rebase will be aborted.
#
</pre>
<p>By changing the first element of a line, you can choose to include the commit, stop rebasing when it gets to that commit (so you can change things), or combine two commits into one.  You can also choose to throw away a commit (by deleting the line) and change the order of commits.  This is the main way to modify git history in a more-than-just-the-most-recent-commit sense.</p>
<p>Remember that <code>git rebase -i</code> can also use the &#8211;onto option, so you could re-order, squash, and modify patches as you change their base from one point in history to another.</p>
<p>Because of how <code>git rebase</code> works, merges can be tricky.  If you have to rebase over a merge (and don&#8217;t want the merge to just be included in one of the patches) be sure to use the -p (&#8211;preserve-merges) option with -i.</p>
<p>Also, because <code>git rebase</code> modifies history, it&#8217;s not a very nice command to run against commits that are publicly available.  Other people don&#8217;t like it when they have commits that depend on your commits and you rewrite the history of your commits.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/gitfu.wordpress.com/9/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/gitfu.wordpress.com/9/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gitfu.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gitfu.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gitfu.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gitfu.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/gitfu.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/gitfu.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/gitfu.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/gitfu.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gitfu.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gitfu.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gitfu.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gitfu.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gitfu.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gitfu.wordpress.com/9/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gitfu.wordpress.com&amp;blog=3324537&amp;post=9&amp;subd=gitfu&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://gitfu.wordpress.com/2008/04/14/git-rebase-when-you-want-to-get-from-here-to-there/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9dc2dafabd66464dbde036a551ce4c70?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">xentac</media:title>
		</media:content>
	</item>
	</channel>
</rss>
