<?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>Mark Kirby - Mobile Developer &#187; github</title>
	<atom:link href="http://mark-kirby.co.uk/tag/github/feed/" rel="self" type="application/rss+xml" />
	<link>http://mark-kirby.co.uk</link>
	<description>I'm a user focused mobile developer, here is where I publish advice and thoughts on building great mobile apps</description>
	<lastBuildDate>Tue, 07 Sep 2010 17:31:29 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Using git and github on OS X</title>
		<link>http://mark-kirby.co.uk/2008/using-git-and-github-on-os-x/</link>
		<comments>http://mark-kirby.co.uk/2008/using-git-and-github-on-os-x/#comments</comments>
		<pubDate>Tue, 30 Sep 2008 16:18:55 +0000</pubDate>
		<dc:creator>kirby.mark</dc:creator>
				<category><![CDATA[tutorial]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[github]]></category>
		<category><![CDATA[osx]]></category>

		<guid isPermaLink="false">http://mark-kirby.co.uk/?p=287</guid>
		<description><![CDATA[Instructions on how to install git on OSX, set up an account with github and contribute to an existing project on there. Its aimed at someone who has been asked to contribute to a codebase in github, but has no idea how.]]></description>
			<content:encoded><![CDATA[<p>git is an alternative to SVN. I&#8217;m just starting out using it, so I&#8217;ll explain how to install it and use the github repository. Once I&#8217;ve got into it more deeply, I&#8217;ll go into detail on the pro&#8217;s and con&#8217;s.</p>
<p>This article is going to be most useful if someone has just asked you to start contributing to an existing project located on github. It covers everything you will need to connect to the project and start editing.</p>
<h2>Install git</h2>
<p>Firstly Download git <a href="http://code.google.com/p/git-osx-installer/">from google code</a>. If you are running a new Mac, you&#8217;ll want the intel version for Leopard.</p>
<p>Run the installer.</p>
<h2>Set up a github account</h2>
<p>Before you can contribute to a github project, you&#8217;ll need a github account.</p>
<p><a href="http://github.com/plans">Go to the plans page</a> and signup for a free open source account.</p>
<h2>Get added to the project</h2>
<p>Send your account username to whoever is running the project you wish to work on, and they can add you to enable access.</p>
<h2>Create a public key and add it to github</h2>
<p>In order to access github you will need to create a public key on your machine and add it to the account. You can do this for each machine you use.</p>
<p>To create the public key run through the <a href="http://github.com/guides/providing-your-ssh-key">github instructions</a> on providing an SSH key for OS X, or use mine:</p>
<h3>Step 1 &#8211; find an existing public key file</h3>
<p>Open terminal</p>
<p>Look for a .pub file inside your .ssh folder by typing</p>
<pre>
<div class="codesnip-container" >
<div class="bash codesnip" style="font-family:monospace;"><span class="kw3">cd</span> .ssh
<span class="kw2">ls</span></div>
</div>
</pre>
<p>If you see a .pub file skip to step 3</p>
<h3>Step 2 &#8211; create a new public key file</h3>
<p>If you don&#8217;t have a .pub file, create one.</p>
<p>In terminal enter</p>
<pre>
<div class="codesnip-container" >
<div class="bash codesnip" style="font-family:monospace;"><span class="kw2">ssh-keygen</span></div>
</div>
</pre>
<p>When prompted to select a name for the file, just hit enter. When asked for a password, enter a selected one and remember it &#8211; you will need this to access github.</p>
<h3>Step 3 &#8211; copy the public key file</h3>
<p>In terminal enter</p>
<pre>
<div class="codesnip-container" >
<div class="bash codesnip" style="font-family:monospace;"><span class="kw2">cat</span> id_rsa.pub <span class="sy0">|</span> pbcopy</div>
</div>
</pre>
<h3>Step 4 &#8211; enter the key into github</h3>
<p>Then <a href="https://github.com/account">access your account details</a> (make sure you are logged in) and locate the SSH Public keys heading. Select &#8220;Add another public key&#8221; and paste (ctrl+V) the key in there.</p>
<h2>Clone the project you wish to contribute to</h2>
<p>To start working on a project, you first need to clone it. The <a href="http://www.kernel.org/pub/software/scm/git/docs/git-clone.html">git clone</a> command is used in this case to download a local copy of the project.</p>
<p>First you must choose a folder on your Mac to place the files. I use my local Sites folder for all code work.</p>
<p>Navigate to this folder from within terminal, e.g.</p>
<pre>
<div class="codesnip-container" >
<div class="bash codesnip" style="font-family:monospace;"><span class="kw3">cd</span> Sites</div>
</div>
</pre>
<p>Clone the project from github using the following command:</p>
<pre>
<div class="codesnip-container" >
<div class="bash codesnip" style="font-family:monospace;">git clone git<span class="sy0">@</span>github.com:accountname<span class="sy0">/</span>repositoryname.git</div>
</div>
</pre>
<p>In the above example, accountname refers to the account name that the project you will work on is stored under, repositoryname is the name of the project.</p>
<p>A folder will be created inside your chosen folder with the name repositoryname, containing all the files.</p>
<h2>Checkout a branch of the project to work on</h2>
<p>To start working on the code you will need to checkout a branch of the clone.</p>
<p>To do this, navigate to the folder which contains the clone using Terminal.</p>
<pre>
<div class="codesnip-container" >
<div class="bash codesnip" style="font-family:monospace;"><span class="kw3">cd</span> Sites<span class="sy0">/</span>repositoryname</div>
</div>
</pre>
<p>Checkout a branch, which you can name myBranch or anything you wish</p>
<pre>
<div class="codesnip-container" >
<div class="bash codesnip" style="font-family:monospace;">git checkout <span class="re5">-b</span> myBranch</div>
</div>
</pre>
<p>This will then switch the files inside the folder to a branch.</p>
<h2>Add and remove files</h2>
<p>When you edit files, you can don&#8217;t need to anything more. </p>
<p>To add a new file, use the command:</p>
<pre>
<div class="codesnip-container" >
<div class="bash codesnip" style="font-family:monospace;">git add path<span class="sy0">/</span>to<span class="sy0">/</span><span class="kw2">file</span></div>
</div>
</pre>
<p>To remove a file (and this also removes it from your local area, so be careful):</p>
<pre>
<div class="codesnip-container" >
<div class="bash codesnip" style="font-family:monospace;">git <span class="kw2">rm</span> path<span class="sy0">/</span>to<span class="sy0">/</span><span class="kw2">file</span></div>
</div>
</pre>
<h2>Commit changes back to the branch when you&#8217;re done</h2>
<p>You can commit changes as often as you like.</p>
<p>Navigate to the folder which contains the clone using Terminal.</p>
<pre>
<div class="codesnip-container" >
<div class="bash codesnip" style="font-family:monospace;"><span class="kw3">cd</span> Sites<span class="sy0">/</span>repositoryname</div>
</div>
</pre>
<p>Commit changes</p>
<pre>
<div class="codesnip-container" >
<div class="bash codesnip" style="font-family:monospace;">git commit <span class="re5">-a</span> <span class="re5">-m</span> <span class="st0">&quot;message&quot;</span></div>
</div>
</pre>
<h2>Rolling back</h2>
<p>To revert back to the state of the last commit, enter the following:</p>
<pre>
<div class="codesnip-container" >
<div class="bash codesnip" style="font-family:monospace;">git reset <span class="re5">--hard</span> HEAD</div>
</div>
</pre>
<h2>Push the branch back to the team</h2>
<p>When you have made all your local changes, you can send them up to the team hosting the project.</p>
<p>Navigate to the folder which contains the clone using Terminal.</p>
<pre>
<div class="codesnip-container" >
<div class="bash codesnip" style="font-family:monospace;"><span class="kw3">cd</span> Sites<span class="sy0">/</span>repositoryname</div>
</div>
</pre>
<p>Push branch</p>
<pre>
<div class="codesnip-container" >
<div class="bash codesnip" style="font-family:monospace;">git push origin myBranch</div>
</div>
</pre>
<p>Remove a branch from the server</p>
<pre>
<div class="codesnip-container" >
<div class="bash codesnip" style="font-family:monospace;">git push origin :myBranch</div>
</div>
</pre>
<h2>Merging changes</h2>
<p>To bring changes down from the main path, first fetch the changes:</p>
<pre>
<div class="codesnip-container" >
<div class="bash codesnip" style="font-family:monospace;">git fetch origin</div>
</div>
</pre>
<p>then merge with your branch</p>
<pre>
<div class="codesnip-container" >
<div class="bash codesnip" style="font-family:monospace;">git merge origin<span class="sy0">/</span>myBranch</div>
</div>
</pre>
<h2>More info</h2>
<p>You should find the following guides useful:</p>
<ul>
<li><a href="http://github.com/guides/home">Github documentation</a></li>
<li><a href="http://www.kernel.org/pub/software/scm/git/docs/user-manual.html">Git User Manual</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://mark-kirby.co.uk/2008/using-git-and-github-on-os-x/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
