<?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>My development blog &#187; git</title>
	<atom:link href="http://www.guztech.nl/wordpress/index.php/tag/git/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.guztech.nl/wordpress</link>
	<description>Drifting in virtual reality...</description>
	<lastBuildDate>Sun, 01 Jan 2012 00:46:44 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Setting up a git server in Ubuntu with gitosis and using gitextensions on Windows</title>
		<link>http://www.guztech.nl/wordpress/index.php/2010/02/setting-up-a-git-server-in-ubuntu-with-gitosis-and-using-gitextensions-on-windows/</link>
		<comments>http://www.guztech.nl/wordpress/index.php/2010/02/setting-up-a-git-server-in-ubuntu-with-gitosis-and-using-gitextensions-on-windows/#comments</comments>
		<pubDate>Thu, 04 Feb 2010 21:14:53 +0000</pubDate>
		<dc:creator>oguz286</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[gitextensions]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://www.guztech.nl/wordpress/?p=50</guid>
		<description><![CDATA[When writing code, you want to use some sort of version control system. Trust me, you want it. I had a project I worked on for 4 weeks and a couple of hours before the deadline I mad a mistake. I was making a class diagram from existing code and realized that a certain UML [...]]]></description>
			<content:encoded><![CDATA[<p>When writing code, you want to use some sort of version control system. Trust me, you want it. I had a project I worked on for 4 weeks and a couple of hours before the deadline I mad a mistake. I was making a class diagram from existing code and realized that a certain UML tool thinks it&#8217;s a good idea to delete a class from the project folder when you decide that you don&#8217;t want that particular class in your diagram. I guess that makes sense&#8230; on a planet where all software developers are masochists.  Anyway, that little mistake could have been a serious problem (and a simple &#8220;Oops, sorry I deleted all the code by accident, kthxbye&#8221; wouldn&#8217;t have cut it), but luckily I had it stored in my dropbox folder which backs everything up on the dropbox servers and they provide an &#8216;undelete&#8217; option.</p>
<p>I&#8217;ve been trying to setup a git server on my server which runs Ubuntu Server 9.10, but I had a lot of problems partly due to the fact that I couldn&#8217;t find a lot of information when something went wrong. But I&#8217;m a stubborn person so I persevered and succeeded in the end. This post is for those who want to setup a git server on Ubuntu and want to use git on Windows, especially with <a title="Git Extensions" href="http://code.google.com/p/gitextensions/" target="_blank"><span style="color: #0099ff;">Git Extensions</span></a>. This tutorial consists of two parts: setting up the server and setting up gitextensions on Windows, but there will be some switching between the server and the local Windows machine so please pay attention.</p>
<p>There are a lot of tutorials that cover setting up a git server but this one is a full guide to setting up a git server and the tools necessary to work with git on Windows. It also has some information I found on some mailing lists and forum posts that I found after a lot of searching. Still I take no credit for this tutorial for it is merely a collection of information I found. All credit goes to the people who actually tested these steps and bothered putting it on the internet for other people struggling with this. I try to explain everything as thorough as possible so it is a lot of text, but it&#8217;s not hard. Just read carefully and you will have git running in no time!</p>
<h2><span id="more-50"></span><span style="color: #0099ff;">Setting up the git server</span></h2>
<p>The server will use the git repository manager <span style="color: #0099ff;"><a href="http://swik.net/gitosis" target="_blank">Gitosis</a></span>. It&#8217;s easy to setup and it just works <img src='http://www.guztech.nl/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>1. Install Ubuntu Server (or any other flavor of Ubuntu) on your server and select the <span style="color: #0099ff;">OpenSSH Server</span> option when asked which packages you want to install. If you don&#8217;t do this or you forget it, don&#8217;t worry, we can add it with a simple command later.</p>
<p>2. Update your server:</p>
<blockquote><p><span style="color: #0099ff;"><em>sudo apt-get update<br />
sudo apt-get dist-upgrade</em></span></p></blockquote>
<p>You can also do <span style="color: #0099ff;"><em>sudo apt-get upgrade</em></span> if you want, but if you&#8217;ve installed a fresh copy of Ubuntu you might as well fully update it. If you haven&#8217;t installed the <span style="color: #0099ff;">OpenSSH Server</span> option install it with:</p>
<blockquote><p><span style="color: #0099ff;"><em>sudo apt-get install ssh</em></span></p></blockquote>
<p>3. Install the <span style="color: #0099ff;">git-core</span> package so we can use git.</p>
<blockquote><p><span style="color: #0099ff;"><em>sudo apt-get install git-core</em></span></p></blockquote>
<p>4. Install the<span style="color: #0099ff;"> python-setuptools</span> package which is needed by <span style="color: #0099ff;">Gitosis</span>.</p>
<blockquote><p><span style="color: #0099ff;"><em>sudo apt-get install python-setuptools</em></span></p></blockquote>
<p>5. Now we can get <span style="color: #0099ff;">Gitosis </span>and set it up.</p>
<blockquote><p><span style="color: #0099ff;"><em>mkdir ~/src<br />
cd ~/src<br />
git clone git://eagain.net/gitosis.git</em></span></p></blockquote>
<p>If everything went fine you should see something like this:</p>
<blockquote><p><span style="color: #0099ff;"><em>Initialized empty Git repository in /home/oguz286/src/gitosis/.git/<br />
remote: Counting objects: 614, done.<br />
remote: Compressing objects: 100% (183/183), done.<br />
remote: Total 614 (delta 434), reused 594 (delta 422)<br />
Receiving objects: 100% (614/614), 93.82 KiB | 134 KiB/s, done.<br />
Resolving deltas: 100% (434/434), done.</em></span></p></blockquote>
<p>6. Time to install <span style="color: #0099ff;">Gitosis</span>.</p>
<blockquote><p><span style="color: #0099ff;"><em>cd gitosis<br />
sudo python setup.py install</em></span></p></blockquote>
<p>7. Setup the &#8216;git&#8217; user.</p>
<blockquote><p><span style="color: #0099ff;"><em>sudo adduser \<br />
&#8211;system \<br />
&#8211;shell /bin/sh \<br />
&#8211;gecos &#8216;git version control&#8217; \<br />
&#8211;group \<br />
&#8211;disabled-password \<br />
&#8211;home /home/git \<br />
git</em></span></p></blockquote>
<p>The <span style="color: #0099ff;">&#8211;home</span> option need not be <span style="color: #0099ff;">/home/git</span> (I placed it on the RAID5 array in my server, instead of the system disk where the <span style="color: #0099ff;">/home</span> folder resides). Notice that the git user doesn&#8217;t have a password. This is because we will be using ssh keys to access our repositories.</p>
<p><span style="color: #0099ff;">Attention:</span> we will switch to the local machine because we need to generate the ssh keys needed by <span style="color: #0099ff;">Gitosis</span> but we are not with the server just yet.</p>
<h2><span style="color: #0099ff;">Setting up gitextensions on Windows</span></h2>
<p>8. Get <span style="color: #0099ff;"><a title="Git Extensions" href="http://code.google.com/p/gitextensions/" target="_blank">Git  Extensions</a></span> and install it on your local Windows machine.  I opted for the option to only add git to my path, so I recommend you do the same since I&#8217;m not sure if it&#8217;s necessary. The other default options are just fine so don&#8217;t change them.<br />
9. Start <span style="color: #0099ff;">Git Extensions</span> and follow the instructions (you probably need to fill in your name and email address that is shown when you commit something). Now click &#8216;<span style="color: #0099ff;">Remotes-&gt;PuTTY-&gt;Generate or import key</span>&#8216;.</p>
<p>This will open <span style="color: #0099ff;">PuTTYgen</span>, which we will use to generate our ssh keys. Click on &#8216;<span style="color: #0099ff;">Generate</span>&#8216; and follow what&#8217;s on the screen. After some the keys will be generated. Change the &#8216;<span style="color: #0099ff;">Key comment</span>&#8216; section to your username but make sure it has no spaces! This is important because <span style="color: #0099ff;">Gitosis</span> will use it as your username and &#8216;rsa-key-2010xxxx&#8217; is a horrible representation of a user. I chose &#8216;OguzMeteer&#8217; because that is my full name.</p>
<p>Make a new file on your desktop called &#8216;<span style="color: #0099ff;">id_rsa.pub</span>&#8216; and put the long string under the &#8216;Public key for pasting&#8230;&#8217; section in that file and put that file on your server (in this example in the <span style="color: #0099ff;">/tmp</span> folder).</p>
<p>Click on &#8216;<span style="color: #0099ff;">Save private key</span>&#8216; and put the file somewhere safe. You will need it shortly.</p>
<p><span style="color: #0099ff;">Attention:</span> the next step is performed on the server!</p>
<p>8. Add your public key to <span style="color: #0099ff;">Gitosis</span>.</p>
<blockquote><p><em><span style="color: #0099ff;">sudo -H -u git gitosis-init &lt; /tmp/id_rsa.pub</span></em></p></blockquote>
<p>You can do this for each person you want to grant access to your repositories.</p>
<p>If everything went allright you should see something like this (depending on where your git user home is):</p>
<blockquote><p><span style="color: #0099ff;"><em>Initialized empty Git repository in /home/git/repositories/gitosis-admin.git/<br />
Reinitialized  empty Git repository in /home/git/repositories/gitosis-admin.git/</em></span></p></blockquote>
<p>Yes it initializes and re-initializes, so don&#8217;t worry. And with that you are done with the server!<br />
9. Connect to your server.<br />
Use <span style="color: #0099ff;"><a href="http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html" target="_blank">PuTTY</a></span> to connect to your server once. This is needed because the first time you connect a server who&#8217;s public key is not known on your system it asks you if you want to accept its public key. Select &#8216;yes&#8217; after connecting to your server and then close <span style="color: #0099ff;">PuTTY</span>.<br />
10. Configure <span style="color: #0099ff;">Gitosis</span>.<br />
This is the cool part because we will configure <span style="color: #0099ff;">Gitosis</span> by using git! In <span style="color: #0099ff;">Git Extensions</span> click on &#8216;<span style="color: #0099ff;">Clone repository</span>&#8216;. You will see this:</p>
<p style="text-align: center;"><a href="http://www.guztech.nl/wordpress/wp-content/uploads/2010/02/clone.png"><img class="aligncenter size-full wp-image-61" title="clone" src="http://www.guztech.nl/wordpress/wp-content/uploads/2010/02/clone.png" alt="Clone repository" width="468" height="248" /></a></p>
<p>For &#8216;<span style="color: #0099ff;">Repository to clone</span>&#8216; fill in:</p>
<blockquote><p><span style="color: #0099ff;"><em>git@yourserverip:gitosis-admin.git</em></span></p></blockquote>
<p><span style="color: #0099ff;">Attention:</span> do not add a &#8216;\&#8217; after it, because then you will get error messages about the command looking dangerous and the server will close the connection! <span style="color: #0099ff;">Git Extensions</span> puts it there sometimes so look out.</p>
<p>&#8216;<span style="color: #0099ff;">Subdirectory to create</span>&#8216; usually is the same name as the repository you want to clone so fill in &#8216;gitosis-admin&#8217;.</p>
<p>Click on &#8216;<span style="color: #0099ff;">Load SSH key</span>&#8216;, select your private key and load it. You will notice that an icon will appear in your taskbar. It is &#8216;Pageant&#8217; and it needs to run when you want to connect to your git repository. Most screw-ups are made here. If it isn&#8217;t running you cannot connect to you repository so make sure it is running. You can also access it through &#8216;<span style="color: #0099ff;">Remotes-&gt;PuTTY-&gt;Start authentication agent</span>&#8216;. If you open it you will see that your private key is in the list and your username that you filled in the comment section is also there.</p>
<p>Finally click on &#8216;<span style="color: #0099ff;">Clone</span>&#8216; and you should get the result you wanted <img src='http://www.guztech.nl/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  <span style="color: #0099ff;"> </span></p>
<p style="text-align: center;"><a href="http://www.guztech.nl/wordpress/wp-content/uploads/2010/02/clonedone.png"><img class="aligncenter size-full wp-image-64" title="clonedone" src="http://www.guztech.nl/wordpress/wp-content/uploads/2010/02/clonedone.png" alt="" width="468" height="217" /></a></p>
<p><span style="color: #0099ff;">Git Extensions</span> asks you if you want to open the repository you just cloned. Do that and you will see the history of the repository (which consists of only 1 commit).</p>
<p>Now you are ready to make your own repositories!</p>
<h2><span style="color: #0099ff;">Setting up repositories</span></h2>
<p>Let&#8217;s say you have a new project called &#8216;<span style="color: #0099ff;">myproject</span>&#8216; and want to make a repository for it on your new server. Open up <span style="color: #0099ff;">gitosis.conf</span> in the directory you cloned it to. Mine contains this:</p>
<blockquote><p><span style="color: #0099ff;"><em>[gitosis]</em></span></p>
<p><em>[group gitosis-admin]<br />
writable = gitosis-admin<br />
members = OguzMeteer</em></p></blockquote>
<p>Let&#8217;s add &#8216;<span style="color: #0099ff;">myproject</span>&#8216; to it. Modify it like this:</p>
<blockquote><p><span style="color: #0099ff;"><em>[gitosis]</em></span></p>
<p><em>[group gitosis-admin]<br />
writable = gitosis-admin<br />
members = OguzMeteer</em></p>
<p><em>[group whatever]<br />
writable = myproject<br />
members = OguzMeteer</em></p></blockquote>
<p>We&#8217;ve made a new group called &#8216;<span style="color: #0099ff;">whatever</span>&#8216;. You can name it whatever you want. What&#8217;s important is the &#8216;<span style="color: #0099ff;">writable</span>&#8216; section where the name of your repository is filled in. &#8216;<span style="color: #0099ff;">members</span>&#8216; obviously is for who has access to the repository. Remember that the name of each member you want to grant access has to be exactly like what you (and they) filled in, in the comment section when generating an ssh key pair (no spaces!).</p>
<p>Now make a folder called <span style="color: #0099ff;">myproject </span>and create a new empty repository in it. To do this click &#8216;<span style="color: #0099ff;">File-&gt;Close</span>&#8216; and then click &#8216;<span style="color: #0099ff;">Create new repository</span>&#8216; in your already opened <span style="color: #0099ff;">Git Extensions</span>. Select your <span style="color: #0099ff;">myproject</span> folder and click &#8216;<span style="color: #0099ff;">Initialize</span>&#8216;. Add some files in the folder and then click &#8216;<span style="color: #0099ff;">Commit</span>&#8216;. Select the files and click &#8216;<span style="color: #0099ff;">Stage selected files</span>&#8216;, write a message and then click &#8216;<span style="color: #0099ff;">Commit</span>&#8216;.</p>
<p>There are only 2 steps left so hang in there! Click &#8216;<span style="color: #0099ff;">Remotes-&gt;Manage remote repositories</span>&#8216; and fill in like in this picture and click &#8216;<span style="color: #0099ff;">Save</span>&#8216;:</p>
<p style="text-align: center;"><a href="http://www.guztech.nl/wordpress/wp-content/uploads/2010/02/remote.png"><img class="aligncenter size-full wp-image-80" title="remote" src="http://www.guztech.nl/wordpress/wp-content/uploads/2010/02/remote.png" alt="" width="470" height="181" /></a></p>
<p style="text-align: left;">Click &#8216;<span style="color: #0099ff;">Yes</span>&#8216;. You will probably get an error, but don&#8217;t worry about it.</p>
<p style="text-align: left;">And the final step! Click &#8216;<span style="color: #0099ff;">Commands-&gt;Push</span>&#8216;, select &#8216;<span style="color: #0099ff;">origin</span>&#8216; next to &#8216;<span style="color: #0099ff;">Remote</span>&#8216;. If everything went fine (it should): Congratulations! You have just made a new repository on your server and committed some files <img src='http://www.guztech.nl/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p style="text-align: left;">To be honest, I don&#8217;t really like <span style="color: #0099ff;">Git Extensions</span> because the Explorer integration isn&#8217;t the best there is. There is a program called <span style="color: #0099ff;">TortoiseGit</span> which is similar to <span style="color: #0099ff;">TortoiseSVN</span> for those of you who are familiar with it. It&#8217;s not as good yet, but I will install it as well and use both <span style="color: #0099ff;">Git Extensions </span>and <span style="color: #0099ff;">TortoiseGit</span>. Happy gitting!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.guztech.nl/wordpress/index.php/2010/02/setting-up-a-git-server-in-ubuntu-with-gitosis-and-using-gitextensions-on-windows/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

