<?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>Dan Dean &#187; git</title>
	<atom:link href="http://dandean.com/category/category/git/feed/" rel="self" type="application/rss+xml" />
	<link>http://dandean.com</link>
	<description></description>
	<lastBuildDate>Wed, 12 May 2010 04:50:29 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>My Very Own GIT Manual</title>
		<link>http://dandean.com/category/code/2009/my-very-own-git-manual/</link>
		<comments>http://dandean.com/category/code/2009/my-very-own-git-manual/#comments</comments>
		<pubDate>Tue, 11 Aug 2009 21:59:05 +0000</pubDate>
		<dc:creator>Dan Dean</dc:creator>
				<category><![CDATA[Code/Projects]]></category>
		<category><![CDATA[git]]></category>

		<guid isPermaLink="false">http://dandean.com/?p=116</guid>
		<description><![CDATA[GIT confuses the hell out of me. I&#8217;m used to Subversion and Vault, and the translation isn&#8217;t always clear. Thankfully, there&#8217;s GitHub which makes it super easy to jump into using GIT. Unfortunately I constantly forget how to do simple tasks, not to speak of complex ones. This post is going to serve as my [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://git-scm.com/" target="_blank">GIT</a> confuses the hell out of me. I&#8217;m used to Subversion and Vault, and the translation isn&#8217;t always clear. Thankfully, there&#8217;s <a href="https://github.com/dandean" target="_blank">GitHub</a> which makes it super easy to jump into using GIT.</p>
<p>Unfortunately I constantly forget how to do simple tasks, not to speak of complex ones. This post is going to serve as my very own GIT manual so I can make these translations easily and not have to remember the intricacies.</p>
<h3>Updating your local repositories with remote changes: <tt> git pull</tt></h3>
<p>To get the latest changes from your remote repository merged into your local master, run <code>git pull</code>. This is pretty much the same as running <code>git fetch</code> then <code>git merge origin/master</code>. Think of this as the GIT version of <code>svn:update</code> or Vault&#8217;s &#8220;Get Latest&#8221;.</p>
<pre>
git pull
</pre>
<h3>Pushing local changes to your remote repository</h3>
<pre>
git add 'your file name'  #do this for each file or folder with changes
git commit -a -m 'Your commit message'
git push origin master
</pre>
<h3>Rejected!</h3>
<p>If a push to your remote repository gets rejected, it&#8217;s probably because remote files have been changed since you last used <tt>git pull</tt>. Run <tt>git pull</tt> then <tt>git push origin/master</tt> again. With any luck you should be in business.</p>
<p>Push master to origin/master</p>
<pre>
git push origin master
> To git@github.com:&lt;username&gt;/&lt;reponame>.git
>  ! [rejected]        master -> master (non-fast forward)
> error: failed to push some refs to 'git@github.com:&lt;username>/&lt;reponame>.git'
</pre>
<p>Damn! Shit&#8217;s broke! Pull again then re-try your push!</p>
<pre>
git pull
> Merge made by recursive.

git push origin master
> Counting objects: 10, done.
> Compressing objects: 100% (5/5), done.
> Writing objects: 100% (6/6), 814 bytes, done.
> Total 6 (delta 1), reused 0 (delta 0)
> To git@github.com:&lt;username>/&lt;reponame>.git
>    65a1527..79239e9  master -> master
</pre>
<p>It worked!</p>
<h3>Updating your fork of another user&#8217;s repository</h3>
<pre>
get fetch origin
git fetch upstream
git merge upstream/master
git push origin master
</pre>
<p>There&#8217;s probably an easier way to do that, but I haven&#8217;t figured out as of this writing.</p>
<h3>Counting the number of commits (and commiters)</h3>
<pre>
git shortlog -s -n
</pre>
<p>This just gives you a nice clean list. The best I can figure out is to clean it up with some regex and count it.</p>
<ul>
<li>Replace all letters and spaces with nothing: <code>[a-z ]+</code></li>
<li>Replace new lines with commas</li>
<li>Wrap the result in array delimiting square brackets</li>
<li>Count it up with JavaScript</li>
</ul>
<pre>
var commits = [744,536,68ö,39,17...1,1,1,1,1,1,1,1,1,1,1];
var count = 0;

commits.forEach(function(x) {
  count += x;
});
console.log(count);
</pre>
<p>If somebody has a better way, please tell me &#8212; this approach is overly complicated.</p>
]]></content:encoded>
			<wfw:commentRss>http://dandean.com/category/code/2009/my-very-own-git-manual/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
