<?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>cakebaker &#187; workflow</title>
	<atom:link href="http://cakebaker.42dh.com/tags/workflow/feed/" rel="self" type="application/rss+xml" />
	<link>http://cakebaker.42dh.com</link>
	<description>baking cakes with CakePHP</description>
	<lastBuildDate>Tue, 20 Dec 2011 15:29:40 +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>A Git workflow for single developers</title>
		<link>http://cakebaker.42dh.com/2009/03/08/a-git-workflow-for-single-developers/</link>
		<comments>http://cakebaker.42dh.com/2009/03/08/a-git-workflow-for-single-developers/#comments</comments>
		<pubDate>Sun, 08 Mar 2009 10:04:40 +0000</pubDate>
		<dc:creator>cakebaker</dc:creator>
				<category><![CDATA[git]]></category>
		<category><![CDATA[workflow]]></category>

		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=1133</guid>
		<description><![CDATA[So far I used Subversion as version control system and my usual workflow is quite simple: IDE =&#62; Subversion repository =&#62; live web application I develop on my local machine, commit the code to the Subversion repository on the server, and finally export the code from the repository to the live application. That works fine. [...]]]></description>
			<content:encoded><![CDATA[<p>So far I used <a href="http://subversion.tigris.org/">Subversion</a> as version control system and my usual workflow is quite simple:</p>
<pre>
<code>IDE =&gt; Subversion repository =&gt; live web application</code>
</pre>
<p>I develop on my local machine, commit the code to the Subversion repository on the server, and finally export the code from the repository to the live application. That works fine.</p>
<p>However, as I wasn&#8217;t able to connect to Subversion repositories from <a href="http://www.netbeans.org/">Netbeans</a> (the IDE I currently use for Ruby-based stuff) for whatever reasons, I had to look for a different solution. I could learn to use Subversion from the command line, or I could use this opportunity to dive a bit more into <a href="http://git-scm.com/">Git</a>. And as you can guess from the subject of this article, I have chosen the second option: Git.</p>
<p>After learning the basics, I looked around to see how others use Git and I found a <a href="http://joemaller.com/2008/11/25/a-web-focused-git-workflow/">web-focused Git workflow</a> by Joe Maller, which I used as a basis for my own workflow. The workflow is:</p>
<pre>
<code>IDE =&gt; local Git repository =&gt; remote bare Git repository =&gt; Git repository with the live web application</code>
</pre>
<p>As you can see, it&#8217;s a bit more complex than the previous workflow, as it involves three repositories instead of one. </p>
<p>I still develop on the local machine, however, now I commit to a local Git repository. From this local repository I push my changes to the remote bare Git repository (&#8220;bare&#8221; meaning the repository doesn&#8217;t have a working directory). This repository then &#8220;notifies&#8221; the Git repository with the live application about the changes, so that this repository can pull the changes from the bare Git repository (technically, this is incorrect, as you will see later). </p>
<p>Ok, now let&#8217;s have a look at how such a workflow is set up.</p>
<p>The first step is to set up the local repository:</p>
<pre>
<code>$ mkdir -p projects/example
$ cd projects/example
$ git init
// create some files
$ git add .
$ git commit -m "Initial commit"</code>
</pre>
<p>For the next step we have to switch to the server, and set up the bare repository:</p>
<pre>
<code>$ mkdir -p git/example.git
$ cd git/example.git
$ git --bare init</code>
</pre>
<p>To be able to push data to this bare repository, we have to tell our local repository about this remote repository. We do this with the following command (on the local machine):</p>
<pre>
<code>$ git remote add exampleserver ssh://exampleuser@example.com/~/git/example.git</code>
</pre>
<p>If everything went well, we can now push the data to the server with the following command:</p>
<pre>
<code>$ git push exampleserver master</code>
</pre>
<p>Tip: if you want to avoid typing the SSH password every time you push data, create a public/private key set as <a href="http://casperfabricius.com/site/2008/09/21/keeping-git-repositories-on-dreamhost-using-ssh/">described</a> by Casper Fabricius.</p>
<p>The next step is to create the repository which will contain the live application. For this purpose we switch again to the server. This time, we create a &#8220;normal&#8221; Git repository, because the working directory will contain the application. As this repository will pull the data from the bare repository, we have to add that bare repository as a &#8220;remote&#8221; repository.</p>
<pre>
<code>$ cd ~
$ mkdir example.org
$ cd example.org
$ git init
$ git remote add bare ~/git/example.git</code>
</pre>
<p>Note: make sure your document root doesn&#8217;t point to &#8220;example.org&#8221; but to a subdirectory!</p>
<p>The final step is to define the &#8220;post-update&#8221; hook script on the bare repository, which is called when the bare repository receives data. To enable the &#8220;post-update&#8221; hook, we have to either make hooks/post-update executable or rename hooks/post-update.sample to hooks/post-update, depending on the Git version. In this script, we simply change to the folder of the live application, and start the pull operation:</p>
<pre>
<code>#!/bin/sh
cd $HOME/example.org
unset GIT_DIR
git pull bare master

exec git-update-server-info</code>
</pre>
<p>Now, with everything set up, we can deploy the application from the local machine with a single command:</p>
<pre>
<code>$ git push exampleserver master</code>
</pre>
<p>I hope I could give you an overview of how a Git workflow for a single developer could look like. Feedback is welcome!</p>
]]></content:encoded>
			<wfw:commentRss>http://cakebaker.42dh.com/2009/03/08/a-git-workflow-for-single-developers/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
		</item>
	</channel>
</rss>

