<?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>jonathanjulian.com &#187; git</title>
	<atom:link href="http://jonathanjulian.com/category/git/feed/" rel="self" type="application/rss+xml" />
	<link>http://jonathanjulian.com</link>
	<description>Ruby, Rails, JavaScript, software development</description>
	<lastBuildDate>Wed, 30 Jun 2010 21:40:38 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>basic git</title>
		<link>http://jonathanjulian.com/2009/08/basic-git/</link>
		<comments>http://jonathanjulian.com/2009/08/basic-git/#comments</comments>
		<pubDate>Sat, 29 Aug 2009 03:44:44 +0000</pubDate>
		<dc:creator>jonathan</dc:creator>
				<category><![CDATA[git]]></category>

		<guid isPermaLink="false">http://jonathanjulian.com/?p=86</guid>
		<description><![CDATA[Sometimes I get asked, &#8220;hey I want to learn git, what should I do?&#8221;. My answer is usually somewhere between read the Pragmatic book, watch the Peepcode, or &#8220;hey, there are only a few commands you&#8217;ll use 80% of the time, I should write them down.&#8221;

So if you just need some basic git, just to get [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes I get asked, &#8220;hey I want to learn git, what should I do?&#8221;. My answer is usually somewhere between <a href="http://www.pragprog.com/titles/tsgit/pragmatic-version-control-using-git">read the Pragmatic book</a>, watch the <a href="http://peepcode.com/products/git">Peepcode</a>, or &#8220;hey, there are only a few commands you&#8217;ll use 80% of the time, I should write them down.&#8221;</p>

<p>So if you just need some basic git, just to get by, this post is for you. Note that this just glosses over the basic commands, you&#8217;ll want to use the man pages and resources on the web such as the free book <a href="http://progit.org/book/">Pro Git</a> to learn more.</p>

<h3>git clone</h3>

<p><span style="font-weight: normal; font-size: 13px; ">This makes a copy of the passed repository and puts it on your machine. Note that <em>git clone</em> will create the directory called &#8216;ext-extensions&#8217; for you. This is the first step to working with an established repository.</span>
<pre>$ git clone git@github.com:jjulian/ext-extensions.git</pre></p>

<h3>git stat</h3>

<h3>git diff</h3>

<p><em>git stat</em> tell you the current status &#8211; what files have changed. And <em>git diff</em> will show you a line by line diff of every file that has changed. Pipe it&#8217;s output to your favorite editor, or to a pager like <em>less</em>.</p>

<h3>git commit</h3>

<p><pre>$ git commit -m "added this new feature" ext-extensions.js</pre>
You have just added your change into your copy of the repository. Pass a meaningful message. You need to specify the file(s) to commit, or -a to commit everything that is modified.</p>

<h3>git push</h3>

<p>Use <em>git push</em> to send all your commits to the origin server. If you don&#8217;t want to send them all, then commit some on a different branch from &#8216;master&#8217;. (this is not hard, but a bit more advanced. Look up <em>git branch</em> and <em>git checkout</em>).
<pre>$ git push origin master</pre>
That&#8217;s the remote repo name (origin) and the branch name (master). These are defaults; you can push/pull to/from more than one remote repo.</p>

<h3>git pull</h3>

<p>Use <em>git pull</em> to integrate changes from another git repo into yours. Similar format as <em>git push</em>.
<pre>$ git pull origin master</pre></p>

<h3>Armed and dangerous</h3>

<p>Armed with the above commands, and a git expert nearby, I guarantee you&#8217;ll be able to survive the day only bothering them once or twice. Here are more tips to keep you going:</p>

<h3>git add</h3>

<p>You can batch your commits to git. Use <em>git add</em> to queue up a bunch of files (or directories) and then commit them all at once using <em>git commit</em>. Very helpful. With this usage, do not specify files on the command line. If you use <em>git add</em>, you also need to use&#8230;</p>

<h3>git diff &#8211;cached</h3>

<p>the <em>&#8211;cached</em> param to diff tells it to diff against the version pending commit, not the version on disk. This can get you in trouble, so before you commit &#8216;added&#8217; files, make sure you have not changed them since the add (of course, this is a feature as well, as you can keep modifying a file but then only commit the original changes. It can get confusing, so just don&#8217;t do it.).</p>

<h3>git checkout &#8212; path/to/file.txt</h3>

<p>You&#8217;ve made some changes to a file, maybe lot&#8217;s of changes, and it&#8217;s all crap. You just want to pull the latest version from the repo and forget you even edited it. This works alot like <em>svn revert</em>.</p>

<p>These are the commands I use every day. There are some more: <em>git log, git merge, git mv, git rm, git reset, git show, git blame</em>&#8230;but I&#8217;ll save these for part 2. The basics are enough to allow a user without too much scm experience to survive changing code and committing files. There&#8217;s plenty of info available on the web for any git situation you may find yourself in, don&#8217;t be afraid, jump on in!</p>

<p><span> </span></p>
]]></content:encoded>
			<wfw:commentRss>http://jonathanjulian.com/2009/08/basic-git/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>svn revert file.rb == git checkout &#8212; file.rb</title>
		<link>http://jonathanjulian.com/2009/03/svn-revert-filerb-git-checkout-filerb/</link>
		<comments>http://jonathanjulian.com/2009/03/svn-revert-filerb-git-checkout-filerb/#comments</comments>
		<pubDate>Fri, 20 Mar 2009 20:52:02 +0000</pubDate>
		<dc:creator>jonathan</dc:creator>
				<category><![CDATA[UNIX]]></category>
		<category><![CDATA[git]]></category>

		<guid isPermaLink="false">http://jonathanjulian.com/?p=37</guid>
		<description><![CDATA[You&#8217;ve changed a file, but don&#8217;t want to commit it. Ever. I do this all the time, maybe disabling a filter so I can hit a page with curl, maybe hard-coding a specific user id to test something. In subversion, you would &#8220;revert&#8221; that file.

svn revert file.rb


In git, you don&#8217;t add that file to your [...]]]></description>
			<content:encoded><![CDATA[<p>You&#8217;ve changed a file, but don&#8217;t want to commit it. Ever. I do this all the time, maybe disabling a filter so I can hit a page with curl, maybe hard-coding a specific user id to test something. In subversion, you would &#8220;revert&#8221; that file.</p>

<pre><code>svn revert file.rb
</code></pre>

<p>In git, you don&#8217;t add that file to your staging area for commit. To make your changes go away forever, you checkout a new copy of that file from HEAD.</p>

<pre><code>git checkout -- file.rb
</code></pre>

<p>If you omit the &#8211;, it will still work, as long as you don&#8217;t have a branch named the same as your file. Thanks to <a href="http://norbauer.com/consulting/team">Jonathan Dance</a> at <a href="http://norbauer.com/notebooks/code/notes/git-revert-reset-a-single-file">norbauer.com</a> &#8211; one of the few blog entries I found describing this technique.</p>

<p><strong><em>2009-04-28 UPDATE</em></strong> &#8211; err has a great <a href="http://cheat.errtheblog.com/s/git/">git cheatsheet</a> that includes this trick under Fixing Mistakes.</p>
]]></content:encoded>
			<wfw:commentRss>http://jonathanjulian.com/2009/03/svn-revert-filerb-git-checkout-filerb/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
