<?xml version="1.0" encoding="UTF-8"?>
<guide>
  <body>&lt;p&gt;&lt;strong&gt;The formatting of the commands on this page is slightly messed up due to Textile &amp;#8211; use the original blog link:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://www.jaisenmathai.com/blog/2008/04/10/how-to-get-started-hosting-your-git-repository-using-github-and-osx/&quot; target=&quot;_blank&quot;&gt;Originally posted on jaisenmathai.com&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Hosting remote git repositories using &lt;a href=&quot;http://github.com&quot; target=&quot;_blank&quot;&gt;GitHub&lt;/a&gt; is completely painless, assuming that you&amp;#8217;ve already signed up for an account at GitHub and that you have Git installed on your computer.  For &lt;span class=&quot;caps&quot;&gt;OSX&lt;/span&gt;, you can use macports to easily get Git&amp;#8217;s command line tools installed.&lt;br /&gt;
&lt;ul&gt;&lt;br /&gt;
	&lt;li&gt;&lt;a href=&quot;#publickeys&quot;&gt;Create your public keys&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;
	&lt;li&gt;&lt;a href=&quot;#makerepo&quot;&gt;Make a repository on GitHub&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;
	&lt;li&gt;&lt;a href=&quot;#remoterepo&quot;&gt;Specify GitHub as a remote repository&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;
	&lt;li&gt;&lt;a href=&quot;#pushcode&quot;&gt;Push your code to GitHub&lt;/a&gt;&lt;/li&gt;&lt;/p&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;a name=&quot;publickeys&quot;&gt;&lt;/a&gt;&lt;h2&gt;Create your public keys&lt;/h2&gt;&lt;br /&gt;
If you haven&amp;#8217;t already given GitHub your public key, you&amp;#8217;ll want to do that now.  If you don&amp;#8217;t already have a public key, let&amp;#8217;s do that first.  Fire up a terminal and do the following:&lt;br /&gt;
&lt;pre class=&quot;console&quot;&gt;user# cd ~/.ssh&lt;br /&gt;
user# ssh-keygen&lt;br /&gt;
Generating public/private rsa key pair.&lt;br /&gt;
Enter file in which to save the key (/Users/username/.ssh/id_rsa): # press enter here&lt;br /&gt;
Enter passphrase (empty for no passphrase): # type in your passphrase here&lt;br /&gt;
Enter same passphrase again: # type your passphrase again&lt;br /&gt;
Your identification has been saved in /Users/username/.ssh/id_rsa.&lt;br /&gt;
Your public key has been saved in /Users/username/.ssh/id_rsa.pub.&lt;br /&gt;
The key fingerprint is:&lt;br /&gt;
50:43:77:c6:97:af:61:82:dc:ea:9b:6b:67:d4:1b:61 user@host&lt;/pre&gt;&lt;br /&gt;
Now that you&amp;#8217;ve generated your public key, you should see it when you do an &lt;tt&gt;ls&lt;/tt&gt;.  Once this is verified, you can copy the contents to your clipboard:&lt;br /&gt;
&lt;pre class=&quot;console&quot;&gt;user# ls&lt;br /&gt;
known_hosts&lt;br /&gt;
id_rsa&lt;br /&gt;
id_rsa.pub&lt;br /&gt;
user# cat id_rsa.pub | pbcopy&lt;/pre&gt;&lt;br /&gt;
Now that your public key is on your &lt;span class=&quot;caps&quot;&gt;OSX&lt;/span&gt; clipboard head on over to &lt;a href=&quot;http://github.com/account&quot; target=&quot;_blank&quot;&gt;http://github.com/account&lt;/a&gt;, paste it in, and save it.&lt;br /&gt;
Note that git expects to use the key named &amp;#8216;id_rsa&amp;#8217; &amp;#8211; if you generate a key with a different name, you&amp;#8217;re likely to get ssh errors.&lt;/p&gt;
&lt;p&gt;&lt;a name=&quot;makerepo&quot;&gt;&lt;/a&gt;&lt;h2&gt;Make a repository on GitHub&lt;/h2&gt;&lt;br /&gt;
Next, you&amp;#8217;ll want to create a repository on GitHub.  Go to &lt;a href=&quot;http://github.com/repositories/new&quot; target=&quot;_blank&quot;&gt;http://github.com/repositories/new&lt;/a&gt; and fill out the form and make note of the project name as we&amp;#8217;ll be using that as the name of your git repository.  Feel free to select either public or private.&lt;/p&gt;
&lt;p&gt;&lt;a name=&quot;remoterepo&quot;&gt;&lt;/a&gt;&lt;h2&gt;Specify GitHub as a remote repository&lt;/h2&gt;&lt;br /&gt;
Let&amp;#8217;s move on to specifying GitHub as a remote repository on your local workstation/laptop.  Head back to your terminal and do the following.&lt;br /&gt;
&lt;pre class=&quot;console&quot;&gt;user# cd ~/repos/my_repo&lt;br /&gt;
user# vi .git/config&lt;/pre&gt;&lt;br /&gt;
You should see a core section and will want to add a remote section.  The name can be anything, but I recommend using something like &amp;#8220;github&amp;#8221; to make it easier to remember what you&amp;#8217;re doing down the road.  Let&amp;#8217;s add the following to the bottom of the config file.&lt;br /&gt;
&lt;pre class=&quot;console&quot;&gt;[remote &amp;#8220;github&amp;#8221;]&lt;br /&gt;
url = git@github.com:git_username/projectname.git&lt;br /&gt;
fetch =  +refs/heads/&lt;strong&gt;:refs/remotes/origin/&lt;/strong&gt;&lt;br /&gt;
push = refs/heads/master:refs/heads/master&lt;/pre&gt;&lt;br /&gt;
Your config file should now look something like this.&lt;br /&gt;
&lt;pre class=&quot;console&quot;&gt;[core]&lt;br /&gt;
repositoryformatversion = 0&lt;br /&gt;
filemode = true&lt;br /&gt;
bare = false&lt;br /&gt;
logallrefupdates = true&lt;br /&gt;
[remote &amp;#8220;github&amp;#8221;]&lt;br /&gt;
url = git@github.com:git_username/projectname.git&lt;br /&gt;
fetch =  +refs/heads/&lt;strong&gt;:refs/remotes/origin/&lt;/strong&gt;&lt;br /&gt;
push = refs/heads/master:refs/heads/master&lt;/pre&gt;&lt;br /&gt;
You can also do this by typing this into your terminal.&lt;br /&gt;
&lt;pre class=&quot;console&quot;&gt;user# git remote add github git@github.com:git_username/projectname.git&lt;/pre&gt;&lt;br /&gt;
&lt;a name=&quot;pushcode&quot;&gt;&lt;/a&gt;&lt;h2&gt;Push your code to GitHub&lt;/h2&gt;&lt;br /&gt;
Both essentially do the same thing, but once you&amp;#8217;ve defined a remote git repository, you can begin pushing your code to it.  Let&amp;#8217;s test it out and see if we can push our git repository to GitHub.&lt;br /&gt;
&lt;pre class=&quot;console&quot;&gt;user# git push github master&lt;br /&gt;
Enter passphrase for key &amp;#8216;/Users/username/.ssh/id_rsa&amp;#8217;: # enter your passphrase here&lt;br /&gt;
updating &amp;#8216;refs/heads/master&amp;#8217;&lt;br /&gt;
from 000000000000000000000000000000&lt;br /&gt;
to   871b8e6c61bc6fca6ee974bc836d70&lt;br /&gt;
Also local refs/remotes/origin/master&lt;br /&gt;
Generating pack&amp;#8230;&lt;br /&gt;
Counting objects: 18&lt;br /&gt;
Done counting 1019 objects.&lt;br /&gt;
Deltifying 1019 objects&amp;#8230;&lt;br /&gt;
100% (1019/1019) done&lt;br /&gt;
Writing 1019 objects&amp;#8230;&lt;br /&gt;
100% (1019/1019) done&lt;br /&gt;
Total 1019 (delta 236), reused 0 (delta 0)&lt;br /&gt;
refs/heads/master: 000000000000000000000000000000 &amp;gt; 871b8e6c61bc6fca6ee974bc836d70&lt;/pre&gt;&lt;br /&gt;
That&amp;#8217;s it!  Now go back to your browser and verify that all your files are showing up.  Go back to &lt;a href=&quot;http://github.com&quot; target=&quot;_blank&quot;&gt;http://github.com&lt;/a&gt; and you should see &amp;#8220;Your Repositories&amp;#8221; to the right-hand side with your project directly underneath it.  Click on your project and you should see your files.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://www.jaisenmathai.com/blog/2008/04/10/how-to-get-started-hosting-your-git-repository-using-github-and-osx/&quot; target=&quot;_blank&quot;&gt;Comment on the original blog post&lt;/a&gt;.&lt;/p&gt;</body>
  <created-at type="datetime">2008-04-11T00:19:23-07:00</created-at>
  <id type="integer">30</id>
  <permalink>setting-up-a-remote-repository-using-github-and-osx</permalink>
  <title>Setting up a remote repository using GitHub and OSX</title>
  <updated-at type="datetime">2009-09-28T14:48:49-07:00</updated-at>
  <user-id type="integer">13400</user-id>
</guide>
