<?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; git</title>
	<atom:link href="http://cakebaker.42dh.com/tags/git/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>Bash autocompletion for Git</title>
		<link>http://cakebaker.42dh.com/2011/04/06/bash-autocompletion-for-git/</link>
		<comments>http://cakebaker.42dh.com/2011/04/06/bash-autocompletion-for-git/#comments</comments>
		<pubDate>Wed, 06 Apr 2011 08:36:05 +0000</pubDate>
		<dc:creator>cakebaker</dc:creator>
				<category><![CDATA[git]]></category>

		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=1514</guid>
		<description><![CDATA[One thing I often wished to have when using Git was the ability to autocomplete Git commands and branch names. As I had to learn this week from Markus Prinz&#8217; article A few of my Git tricks, tips and workflows, Git comes with an autocompletion script for the Bash shell. But to use the autocompletion, [...]]]></description>
			<content:encoded><![CDATA[<p>One thing I often wished to have when using <a href="http://git-scm.com/">Git</a> was the ability to autocomplete Git commands and branch names. As I had to learn this week from Markus Prinz&#8217; article <a href="http://nuclearsquid.com/writings/git-tricks-tips-workflows.html">A few of my Git tricks, tips and workflows</a>, Git comes with an autocompletion script for the <a href="http://en.wikipedia.org/wiki/Bash_(Unix_shell)">Bash</a> shell. </p>
<p>But to use the autocompletion, you have to enable it. To do that, add the following snippet to your <code>~/.bashrc</code> file (if you are using a Mac, see the aforementioned <a href="http://nuclearsquid.com/writings/git-tricks-tips-workflows.html">article</a>):</p>
<pre>
<code>source /etc/bash_completion.d/git</code>
</pre>
<p>You can then either reload the <code>.bashrc</code> file with <code>source ~/.bashrc</code> or open a new shell to see the autocompletion in action.</p>
]]></content:encoded>
			<wfw:commentRss>http://cakebaker.42dh.com/2011/04/06/bash-autocompletion-for-git/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Quicktip: Exporting from a bare Git repository</title>
		<link>http://cakebaker.42dh.com/2009/08/06/quicktip-exporting-from-a-bare-git-repository/</link>
		<comments>http://cakebaker.42dh.com/2009/08/06/quicktip-exporting-from-a-bare-git-repository/#comments</comments>
		<pubDate>Thu, 06 Aug 2009 13:37:30 +0000</pubDate>
		<dc:creator>cakebaker</dc:creator>
				<category><![CDATA[git]]></category>
		<category><![CDATA[tip]]></category>

		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=1228</guid>
		<description><![CDATA[Recently I had to export the latest version of a project from a bare Git repository. As it seems like there is no equivalent to svn export in Git, I had to look for an alternative. After some searching I found the following solution: $ cd ~/example.git $ git archive master &#124; tar -x -C [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I had to export the latest version of a project from a bare Git repository. As it seems like there is no equivalent to <a href="http://svnbook.red-bean.com/en/1.5/svn.ref.svn.c.export.html">svn export</a> in <a href="http://git-scm.com/">Git</a>, I had to look for an alternative. After some searching I found the following <a href="http://stackoverflow.com/questions/160608/how-to-do-a-git-export-like-svn-export/163769#163769">solution</a>:</p>
<pre>
<code>$ cd ~/example.git
$ git archive master | tar -x -C /path/to/target/folder</code>
</pre>
<p>The first part of this statement creates a tar archive with the content of the master branch. The second part then extracts this archive to the specified folder (-x means &#8220;extract&#8221;, and -C means &#8220;change to directory&#8221;).</p>
<p>I hope this is useful for some of you!</p>
]]></content:encoded>
			<wfw:commentRss>http://cakebaker.42dh.com/2009/08/06/quicktip-exporting-from-a-bare-git-repository/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<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>

