<?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>newthink.net &#187; ubuntu</title>
	<atom:link href="http://www.newthink.net/tag/ubuntu/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.newthink.net</link>
	<description>Less Talk. More Do.</description>
	<lastBuildDate>Tue, 26 Jan 2010 18:28:51 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Simple Central Git Repository</title>
		<link>http://www.newthink.net/2009/09/20/simple-central-git-repository/</link>
		<comments>http://www.newthink.net/2009/09/20/simple-central-git-repository/#comments</comments>
		<pubDate>Sun, 20 Sep 2009 23:09:29 +0000</pubDate>
		<dc:creator>Ash Christopher</dc:creator>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[dvcs]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[source control]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[version control]]></category>

		<guid isPermaLink="false">http://www.newthink.net/?p=154</guid>
		<description><![CDATA[I have a new project that I am starting, and instead of using the familiar subversion for source control, I figured this was a great time to check out Git. An added bonus is we are looking at switching over to it at work &#8211; two birds.
The first thing you need to do is install [...]]]></description>
			<content:encoded><![CDATA[<p>I have a new project that I am starting, and instead of using the familiar subversion for source control, I figured this was a great time to check out Git. An added bonus is we are looking at switching over to it at work &#8211; two birds.</p>
<div id="attachment_165" class="wp-caption aligncenter" style="width: 311px"><img class="size-full wp-image-165  " title="Distributed Source Control" src="http://www.newthink.net/wp-content/uploads/2009/09/drawing1.jpg" alt="" width="301" height="177" /><p class="wp-caption-text">Users can push and pull from other users or from a central repository. </p></div>
<p>The first thing you need to do is install git on both your clients and server. I am using Ubuntu, so you will have to figure out the equivalent commands and package names.</p>
<pre style="padding-left: 30px;">(client)$ sudo apt-get install git git-core

(server)$ sudo apt-get install git git-core</pre>
<p>Now that we have git on our server and client, we can start creating the git repository we want under source control.</p>
<p>The first thing we will do is create a git project. This can either be an existing code base you are already working on, or you can start a project from scratch. For the purposes of this example, we will start a new project.</p>
<pre style="padding-left: 30px;">(client)$ mkdir project
(client)$ cd project
(client)$ git init</pre>
<p>Git should reply with the message &#8216;<strong>Initialized empty Git repository in .git/</strong>&#8216;. Make a note of the .git directory created in our project &#8211; we will need it shortly.</p>
<p>I ran into my first issue here &#8211; the version of git I am using doesn&#8217;t seem to like to clone empty repositories. In order to allow me to clone (as you will see further down the page), we must have an initial commit.</p>
<pre style="padding-left: 30px;">(client)$ touch README
(client)$ git add README
(client)$ git commit -m "Initial commit." README</pre>
<p>We want this new project to be available on a central Git repository (centralized decentralized version control system &#8211; the irony is not lost on me). The easiest way is to just <strong>scp </strong>the .git directory to the server and place them in the directory you plan on containing your repositories. In my case, I created a <strong>git </strong>directory off of <strong>/</strong> on the server.</p>
<pre style="padding-left: 30px;">(server)$ sudo mkdir /git

(client)$ git clone --bare project project.git
(client)$ scp -r project.git user@server:/git/</pre>
<p>Essentially, we are finished adding the repository to the central server. We can now access the git repo from all clients so long as those users have ssh access to the central server. By default, we can access the repo from the clients using the ssh interface.</p>
<pre style="padding-left: 30px;">(client)$ git pull user@server:/git/project.git master</pre>
<p>And we can push changes to the repo in a similar fashion.</p>
<pre style="padding-left: 30px;">(client)$ git push user@server:/git/project.git master</pre>
<p>This is about as simple a set up as you can have. The Git server is really quite dumb. The real magic happens on the client side (which is left for another post when I have done a bit more research).</p>
<p>By default, this git server is private. Only users that have shell access to the server have access to push and pull changes. Push access requires private access, but for projects which you want public access, you can set up a <a href="http://www.kernel.org/pub/software/scm/git/docs/git-daemon.html">git-daemon</a> to serve git clone requests from the public. Rather than run it as a persistent process, you can quite simply tie it into <strong>xinetd </strong>with this simple configuration (remember, I am using Ubuntu).</p>
<pre style="padding-left: 30px;">(server)$ touch /git/project.git/git-daemon-export-ok
(server)$ sudo apt-get install xinetd
(server)$ sudo vi /etc/xinetd.d/git</pre>
<pre style="padding-left: 60px;">service git
{
    disable = no
    type = UNLISTED
    port = 9418
    socket_type = stream
    wait = no
    user = nobody
    server = /usr/bin/git-daemon
    server_args = --inetd --export-all --base-path=/git
}</pre>
<pre style="padding-left: 30px;">(server)$ sudo /etc/init.d/xinetd restart</pre>
<p>This now gives us a public git repository url we can distribute to others.</p>
<pre style="padding-left: 30px;">(client)$ git clone git://server/project.git</pre>
<p>Just remember that you still need to push changes to the repo via ssh.</p>
<h2><strong>UPDATE</strong></h2>
<p>Talked to one of the guys in #git on irc.freenode.net and he informed me that the usual practice is to create the git repo on the central server first, then clone it to the client and push changes from the client.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.newthink.net/2009/09/20/simple-central-git-repository/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
