<?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>mcBachmann.de TechBlog &#187; split patch</title>
	<atom:link href="http://blog.mcbachmann.de/tag/split-patch/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.mcbachmann.de</link>
	<description>Der Blog zur Website ;-)</description>
	<lastBuildDate>Wed, 11 Jan 2012 21:12:53 +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>git: Only commit parts of a patched file (hunk-checkin)</title>
		<link>http://blog.mcbachmann.de/linux/git-only-commit-parts-of-a-patched-file-hunk-checkin</link>
		<comments>http://blog.mcbachmann.de/linux/git-only-commit-parts-of-a-patched-file-hunk-checkin#comments</comments>
		<pubDate>Sun, 19 Jul 2009 20:02:59 +0000</pubDate>
		<dc:creator>Sven Bachmann</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[split patch]]></category>

		<guid isPermaLink="false">http://blog.mcbachmann.de/?p=344</guid>
		<description><![CDATA[Hi, today I read Og Maciels blog entry on Planet GNOME about how he find out to not checkin a whole changed file with git but include/exclude special parts. This is something I needed in the last time much often, but never thought it exists &#8211; so with git its very easy. Now lets have [...]]]></description>
			<content:encoded><![CDATA[<p>Hi, today I read <a href="http://www.ogmaciel.com/?p=721">Og Maciels blog entry</a> on <em>Planet GNOME</em> about how he find out to not checkin a whole changed file with git but include/exclude special parts. This is something I needed in the last time much often, but never thought it exists &#8211; so with git its very easy.<span id="more-344"></span></p>
<p>Now lets have an example, we call it <strong>story.txt</strong>. It contains the following:</p>
<blockquote><p><code>The New Kitten</p>
<p>After their holidays, Ann and Joe decided to get an malani which should be their everyday joy. They decided to get a cat.</p>
<p>It was about 2 weeks old when they take it home and tried everything to make it feel comfortable.</p>
<p>In the end everybody was happy and they lived long and prosper.</code></p></blockquote>
<p>So after this was checked in, we see the mistakes&#8230; it should be an <strong>animal</strong>, not an <strong>malani</strong> and while we correct this, we also fixed the <strong>2 weeks</strong> &#8211; because a kitten should not be taken from its mother before the <strong>7th week</strong>.</p>
<p>Now we wanted to check in both changes &#8211; but separatly, because the <strong>malani</strong> was a typo and the <strong>2 weeks</strong> were a logical error.</p>
<p>How to do so with git?</p>
<blockquote><p><code>git add --patch story.txt</p>
<p>diff --git a/story.txt b/story.txt<br />
index 74fb958..7d7e63b 100644<br />
--- a/story.txt<br />
+++ b/story.txt<br />
@@ -1,7 +1,7 @@<br />
 The New Kitten</p>
<p>-After their holidays, Ann and Joe decided to get an malani which should be their everyday joy. They decided to get a cat.<br />
+After their holidays, Ann and Joe decided to get an animal which should be their everyday joy. They decided to get a cat.</p>
<p>-It was about 2 weeks old when they take it home and tried everything to make it feel comfortable.<br />
+It was about 7 weeks old when they take it home and tried everything to make it feel comfortable.</p>
<p> In the end everybody was happy and they lived long and prosper.<br />
Stage this hunk [y/n/a/d/s/e/?]? </code></p></blockquote>
<p>This is how <em>git</em> sees it at first &#8211; two changes which belong together, because they are neighbours. But we want to change this, so we use the <em>s</em>-key for <em>split</em>.</p>
<blockquote><p><code>Stage this hunk [y/n/a/d/s/e/?]? s<br />
Split into 2 hunks.<br />
@@ -1,4 +1,4 @@<br />
 The New Kitten</p>
<p>-After their holidays, Ann and Joe decided to get an malani which should be their everyday joy. They decided to get a cat.<br />
+After their holidays, Ann and Joe decided to get an animal which should be their everyday joy. They decided to get a cat.</p>
<p>Stage this hunk [y/n/a/d/j/J/e/?]? y<br />
@@ -4,4 +4,4 @@</p>
<p>-It was about 2 weeks old when they take it home and tried everything to make it feel comfortable.<br />
+It was about 7 weeks old when they take it home and tried everything to make it feel comfortable.</p>
<p> In the end everybody was happy and they lived long and prosper.<br />
Stage this hunk [y/n/a/d/K/e/?]? n</code></p></blockquote>
<p>Now you can easily checkin the first change with <em>git commit</em> and than add the second change with <em>git add story.txt</em> (of course you can also split it again into hunks &#8211; if your changes are bigger).</p>
<p>Good luck and thanks to Og.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mcbachmann.de/linux/git-only-commit-parts-of-a-patched-file-hunk-checkin/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

