<?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>Nick Zalabak - techwhizbang &#187; git</title>
	<atom:link href="http://techwhizbang.com/tag/git/feed/" rel="self" type="application/rss+xml" />
	<link>http://techwhizbang.com</link>
	<description>my work, life, and ideas</description>
	<lastBuildDate>Wed, 25 Jan 2012 05:47:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>Git cheat sheet</title>
		<link>http://techwhizbang.com/2010/07/git-cheat-sheet/</link>
		<comments>http://techwhizbang.com/2010/07/git-cheat-sheet/#comments</comments>
		<pubDate>Mon, 12 Jul 2010 23:13:43 +0000</pubDate>
		<dc:creator>techwhizbang</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[git]]></category>

		<guid isPermaLink="false">http://techwhizbang.com/?p=294</guid>
		<description><![CDATA[This is my personal Git cheat sheet. It is really a mish-mosh of other resources across the web. Yep, there are a million of them. This one isn&#8217;t special, but it is useful to me. If it works for you too, awesome; if not, move on. create a remote branch from master git checkout -b [...]]]></description>
			<content:encoded><![CDATA[<p>This is <em>my</em> personal Git cheat sheet. It is really a mish-mosh of other resources across the web. Yep, there are a million of them. This one isn&#8217;t special, but it is useful to me. If it works for you too, awesome; if not, move on.</p>
<p><strong>create a remote branch from master</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">git</span> checkout <span style="color: #660033;">-b</span> branch_name master
<span style="color: #c20cb9; font-weight: bold;">git</span> push origin branch_name</pre></div></div>

<p><strong>delete a remote branch</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">git</span> push origin :branch_name</pre></div></div>

<p><strong>switching between branches on your local</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">git</span> checkout branch_name</pre></div></div>

<p><strong>merging and tagging a release branch to master</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">git</span> checkout master
<span style="color: #c20cb9; font-weight: bold;">git</span> merge <span style="color: #660033;">--no-ff</span> release_branch_name
<span style="color: #666666; font-style: italic;">#fix any potential merge conflicts (there should be any) and commit</span>
<span style="color: #c20cb9; font-weight: bold;">git</span> tag <span style="color: #660033;">-a</span> <span style="color: #000000;">2010</span>.xxx
<span style="color: #c20cb9; font-weight: bold;">git</span> push <span style="color: #660033;">--tags</span></pre></div></div>

<p><strong>merging a feature branch back into development</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">git</span> checkout development
<span style="color: #c20cb9; font-weight: bold;">git</span> merge <span style="color: #660033;">--no-ff</span> myfeature_branch
<span style="color: #c20cb9; font-weight: bold;">git</span> push origin development
 <span style="color: #666666; font-style: italic;"># (optionally delete the feature branch, git branch -d myfeature_branch)</span></pre></div></div>

<p><strong>bug fixing and patching between branches</strong><br />
Depending on where you are working, commit your fix to the appropriate branch<br />
Then use:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">git</span> log <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">less</span>
<span style="color: #666666; font-style: italic;"># Find your revision (it should be one the latest ones)</span>
<span style="color: #c20cb9; font-weight: bold;">git</span> <span style="color: #c20cb9; font-weight: bold;">diff</span> your_revision_hash <span style="color: #000000; font-weight: bold;">&amp;</span>gt; <span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>my_patch <span style="color: #7a0874; font-weight: bold;">&#40;</span>ex. <span style="color: #c20cb9; font-weight: bold;">git</span> <span style="color: #c20cb9; font-weight: bold;">diff</span> cfbe9041b <span style="color: #000000; font-weight: bold;">&amp;</span>gt; <span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>my_patch<span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #c20cb9; font-weight: bold;">git</span> checkout branch_you_want_to_apply <span style="color: #c20cb9; font-weight: bold;">patch</span>
<span style="color: #c20cb9; font-weight: bold;">git</span> apply <span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>my_patch
<span style="color: #666666; font-style: italic;"># continue committing and pushing as you would normally</span></pre></div></div>

<p><strong>Aside from merging, sometimes you want to just pick one commit from a different branch. To apply the changes in revision rev and commit them to the current branch use:</strong><br />
note: try patching first, if patching isn&#8217;t working well then try cherry picking the revision(s)</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">git</span> cherry-pick revision_hash</pre></div></div>

<p><strong>merging release branch hot-fix and bug fixes to development branch</strong><br />
note: Patching and cherry picking are preferred over full merging</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">git</span> checkout development
<span style="color: #c20cb9; font-weight: bold;">git</span> merge <span style="color: #660033;">--no-ff</span> release_name</pre></div></div>

<p><strong>stash your changes for later</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">git</span> stash</pre></div></div>

<p><strong>find out what is in your stash list</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">git</span> stash list</pre></div></div>

<p><strong>apply your stash</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">git</span> stash apply</pre></div></div>

<p><strong>clear your stash</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">git</span> stash <span style="color: #c20cb9; font-weight: bold;">clear</span></pre></div></div>

<p><strong>notes about your .git/config</strong></p>
<p>You&#8217;ll need to make changes to this as often as you contribute to the different number of branches being used for your project. Meaning if you have to commit to the development branch, latest release branch(es), and merge into the master branch &#8211; these all need to be in your .git/config file. Here is an example. Notice the rebase = true on the development branch and how it is commented out for the release branch &#8220;Alkonost&#8221;.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>branch <span style="color: #ff0000;">&quot;master&quot;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>
remote = origin
merge = refs<span style="color: #000000; font-weight: bold;">/</span>heads<span style="color: #000000; font-weight: bold;">/</span>master
&nbsp;
<span style="color: #7a0874; font-weight: bold;">&#91;</span>branch <span style="color: #ff0000;">&quot;development&quot;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>
remote = origin
merge = refs<span style="color: #000000; font-weight: bold;">/</span>heads<span style="color: #000000; font-weight: bold;">/</span>development
rebase = <span style="color: #c20cb9; font-weight: bold;">true</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">&#91;</span>branch <span style="color: #ff0000;">&quot;ReleaseBranch&quot;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>
remote = origin
merge = refs<span style="color: #000000; font-weight: bold;">/</span>heads<span style="color: #000000; font-weight: bold;">/</span>ReleaseBranch
rebase = <span style="color: #c20cb9; font-weight: bold;">true</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://techwhizbang.com/2010/07/git-cheat-sheet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic page generated in 1.963 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2012-02-06 15:20:03 -->

