<?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>Stephen Cott</title>
	<atom:link href="http://stephencott.com/feed" rel="self" type="application/rss+xml" />
	<link>http://stephencott.com</link>
	<description></description>
	<lastBuildDate>Thu, 15 Dec 2011 19:55:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Setting up my git server</title>
		<link>http://stephencott.com/archives/5</link>
		<comments>http://stephencott.com/archives/5#comments</comments>
		<pubDate>Wed, 14 Dec 2011 03:39:20 +0000</pubDate>
		<dc:creator>stephen</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Dev]]></category>

		<guid isPermaLink="false">http://stephencott.com/?p=5</guid>
		<description><![CDATA[I just wanted to get this written down somewhere before I forget how I did it or forget how to use it. I installed git on my server. I added my ssh key to the server: scp ~/.ssh/id_rsa.pub &#91;username&#93;@&#91;server&#93;:.ssh/authorized_keys I then wrote the following script (I actually stole most of it but that&#8217;s moot. Credit [...]]]></description>
			<content:encoded><![CDATA[<p>I just wanted to get this written down somewhere before I forget how I did it or forget how to use it.</p>
<p>I installed git on my server. I added my ssh key to the server:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">scp</span> ~<span style="color: #000000; font-weight: bold;">/</span>.ssh<span style="color: #000000; font-weight: bold;">/</span>id_rsa.pub <span style="color: #7a0874; font-weight: bold;">&#91;</span>username<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #000000; font-weight: bold;">@</span><span style="color: #7a0874; font-weight: bold;">&#91;</span>server<span style="color: #7a0874; font-weight: bold;">&#93;</span>:.ssh<span style="color: #000000; font-weight: bold;">/</span>authorized_keys</pre></div></div>

<p>I then wrote the following script (I actually stole most of it but that&#8217;s moot. Credit goes to <a href="http://johanharjono.com/archives/862">Johan Harjono</a>)</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span>
<span style="color: #666666; font-style: italic;">#####################################</span>
<span style="color: #666666; font-style: italic;"># Stephen Cott</span>
<span style="color: #666666; font-style: italic;"># 10 DEC 2011</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># createGitRepo.sh</span>
<span style="color: #666666; font-style: italic;"># Script to create a local git</span>
<span style="color: #666666; font-style: italic;"># repository and configure it on a</span>
<span style="color: #666666; font-style: italic;"># remote server</span>
<span style="color: #666666; font-style: italic;">#####################################</span>
&nbsp;
<span style="color: #007800;">repo_name</span>=<span style="color: #007800;">$1</span>
<span style="color: #007800;">language</span>=<span style="color: #007800;">$2</span>
<span style="color: #007800;">remote_user</span>=xxxx
<span style="color: #007800;">remote_server</span>=xxxx
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #007800;">$repo_name</span>
<span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #007800;">$repo_name</span>
<span style="color: #c20cb9; font-weight: bold;">git</span> init
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">touch</span> README
<span style="color: #c20cb9; font-weight: bold;">git</span> add README
<span style="color: #c20cb9; font-weight: bold;">git</span> commit <span style="color: #660033;">-m</span> <span style="color: #ff0000;">&quot;Initial Commit&quot;</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">cd</span> ..
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">git</span> clone <span style="color: #660033;">--bare</span> <span style="color: #007800;">$repo_name</span> <span style="color: #800000;">${repo_name}</span>.git
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">scp</span> <span style="color: #660033;">-r</span> <span style="color: #800000;">${repo_name}</span>.git <span style="color: #800000;">${remote_user}</span><span style="color: #000000; font-weight: bold;">@</span><span style="color: #800000;">${remote_server}</span>:~<span style="color: #000000; font-weight: bold;">/</span>code<span style="color: #000000; font-weight: bold;">/</span><span style="color: #800000;">${language}</span><span style="color: #000000; font-weight: bold;">/</span>
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-Rf</span> <span style="color: #800000;">${repo_name}</span>.git
&nbsp;
<span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #007800;">$repo_name</span>
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">git</span> remote add <span style="color: #007800;">$repo_name</span> <span style="color: #c20cb9; font-weight: bold;">ssh</span>:<span style="color: #000000; font-weight: bold;">//</span><span style="color: #800000;">${remote_user}</span><span style="color: #000000; font-weight: bold;">@</span><span style="color: #800000;">${remote_server}</span><span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">&#91;</span>username<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #000000; font-weight: bold;">/</span>code<span style="color: #000000; font-weight: bold;">/</span><span style="color: #800000;">${language}</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #800000;">${repo_name}</span>.git</pre></div></div>

<p>That script creates a new directory in the current directory using the first argument, the it initializes the directory for git. After that it clones the git repository to same name .git and initialzes a bare git structure. Then it scp&#8217;s that git repository up to my server into a subdirectory of code dependent on the second argument which is the language type and deletes the local *.git copy. Finally it moves back into the newly created project folder and sets up a git remote.</p>
<p>It&#8217;s pretty simple to use after that. If I am working on another system and want to pull a project I would 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> clone <span style="color: #c20cb9; font-weight: bold;">ssh</span>:<span style="color: #000000; font-weight: bold;">//</span><span style="color: #7a0874; font-weight: bold;">&#91;</span>username<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #000000; font-weight: bold;">@</span><span style="color: #7a0874; font-weight: bold;">&#91;</span>server<span style="color: #7a0874; font-weight: bold;">&#93;</span>:<span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">&#91;</span>username<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #000000; font-weight: bold;">/</span>code<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">&#91;</span>language<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">&#91;</span>reponame<span style="color: #7a0874; font-weight: bold;">&#93;</span>.git <span style="color: #7a0874; font-weight: bold;">&#91;</span>localreponame<span style="color: #7a0874; font-weight: bold;">&#93;</span></pre></div></div>

<p>Do whatever work I need to do on the project and then:</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</pre></div></div>

<p>When I&#8217;m back at my main workstation I just need to do:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>localreponame<span style="color: #7a0874; font-weight: bold;">&#93;</span>
<span style="color: #c20cb9; font-weight: bold;">git</span> pull</pre></div></div>

<p>And then my main workstation is up to date.</p>
]]></content:encoded>
			<wfw:commentRss>http://stephencott.com/archives/5/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

