<?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>eXpand yOur cReativity &#187; git</title>
	<atom:link href="http://blog.bhushangahire.net/tag/git/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.bhushangahire.net</link>
	<description>by Bhushan G Ahire</description>
	<lastBuildDate>Mon, 26 Jul 2010 10:25:25 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Setup Capistrano to deploy Rails application on Amazon EC2 with Git</title>
		<link>http://blog.bhushangahire.net/2010/02/17/setup-capistrano-to-deploy-rails-application-on-amazon-ec2-with-git/</link>
		<comments>http://blog.bhushangahire.net/2010/02/17/setup-capistrano-to-deploy-rails-application-on-amazon-ec2-with-git/#comments</comments>
		<pubDate>Wed, 17 Feb 2010 06:22:49 +0000</pubDate>
		<dc:creator>Bhushan G Ahire</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Subversion]]></category>
		<category><![CDATA[capistrano]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[ec2]]></category>
		<category><![CDATA[server]]></category>

		<guid isPermaLink="false">http://blog.bhushangahire.net/?p=155</guid>
		<description><![CDATA[
1: Create a new Rails app &#8211; we&#8217;ll call is &#8216;deploytest&#8217;
$ rails deploytest
$ cd deploytest
2: Create a local Git repository for it
$ git init
$ git add *
$ git commit -a -m 'initial commit'
$ git status
3: Create a couple of Capistrano files
$ capify .
4: Edit config/deploy.rb
# The name of your app
set :application, "deploytest"
# The directory on [...]]]></description>
			<content:encoded><![CDATA[<div class="fblike_button" style="margin: 10px 0;"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fblog.bhushangahire.net%2F2010%2F02%2F17%2Fsetup-capistrano-to-deploy-rails-application-on-amazon-ec2-with-git%2F&amp;layout=standard&amp;show_faces=false&amp;width=450&amp;action=recommend&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:450px; height:25px"></iframe></div>
<div class="post-body entry-content">1: Create a new Rails app &#8211; we&#8217;ll call is &#8216;deploytest&#8217;</p>
<pre class="prettyprint"><span class="pln">$ rails deploytest
$ cd deploytest</span></pre>
<p>2: Create a local Git repository for it</p>
<pre class="prettyprint"><span class="pln">$ git init
$ git add </span><span class="pun">*</span><span class="pln">
$ git commit </span><span class="pun">-</span><span class="pln">a </span><span class="pun">-</span><span class="pln">m </span><span class="str">'initial commit'</span><span class="pln">
$ git status</span></pre>
<p>3: Create a couple of Capistrano files</p>
<pre class="prettyprint"><span class="pln">$ capify </span><span class="pun">.</span></pre>
<p>4: Edit config/deploy.rb</p>
<pre class="prettyprint"><span class="com"># The name of your app</span><span class="pln">
</span><span class="kwd">set</span><span class="pln"> </span><span class="pun">:</span><span class="pln">application</span><span class="pun">,</span><span class="pln"> </span><span class="str">"deploytest"</span><span class="pln">
</span><span class="com"># The directory on the EC2 node that will be deployed to</span><span class="pln">
</span><span class="kwd">set</span><span class="pln"> </span><span class="pun">:</span><span class="pln">deploy_to</span><span class="pun">,</span><span class="pln"> </span><span class="str">"/var/www/apps/#{application}"</span><span class="pln">
</span><span class="com"># The type of Source Code Management system you are using</span><span class="pln">
</span><span class="kwd">set</span><span class="pln"> </span><span class="pun">:</span><span class="pln">scm</span><span class="pun">,</span><span class="pln"> </span><span class="pun">:</span><span class="pln">git
</span><span class="com"># The location of the LOCAL repository relative to the current app</span><span class="pln">
</span><span class="kwd">set</span><span class="pln"> </span><span class="pun">:</span><span class="pln">repository</span><span class="pun">,</span><span class="pln">  </span><span class="str">"."</span><span class="pln">
</span><span class="com"># The way in which files will be transferred from repository to remote host</span><span class="pln">
</span><span class="com"># If you were using a hosted github repository this would be slightly different</span><span class="pln">
</span><span class="kwd">set</span><span class="pln"> </span><span class="pun">:</span><span class="pln">deploy_via</span><span class="pun">,</span><span class="pln"> </span><span class="pun">:</span><span class="pln">copy

</span><span class="com"># The address of the remote host on EC2 (the Public DNS address)</span><span class="pln">
</span><span class="kwd">set</span><span class="pln"> </span><span class="pun">:</span><span class="pln">location</span><span class="pun">,</span><span class="pln"> </span><span class="str">"ec2-xxx-xxx-xxx-xxx.compute-1.amazonaws.com"</span><span class="pln">
</span><span class="com"># setup some Capistrano roles</span><span class="pln">
role </span><span class="pun">:</span><span class="pln">app</span><span class="pun">,</span><span class="pln"> location
role </span><span class="pun">:</span><span class="pln">web</span><span class="pun">,</span><span class="pln"> location
role </span><span class="pun">:</span><span class="pln">db</span><span class="pun">,</span><span class="pln">  location</span><span class="pun">,</span><span class="pln"> </span><span class="pun">:</span><span class="pln">primary </span><span class="pun">=&gt;</span><span class="pln"> </span><span class="kwd">true</span><span class="pln">

</span><span class="com"># Set up SSH so it can connect to the EC2 node - assumes your SSH key is in ~/.ssh/id_rsa</span><span class="pln">
</span><span class="kwd">set</span><span class="pln"> </span><span class="pun">:</span><span class="pln">user</span><span class="pun">,</span><span class="pln"> </span><span class="str">"root"</span><span class="pln">
ssh_options</span><span class="pun">[:</span><span class="pln">keys</span><span class="pun">]</span><span class="pln"> </span><span class="pun">=</span><span class="pln"> </span><span class="pun">[</span><span class="typ">File</span><span class="pun">.</span><span class="pln">join</span><span class="pun">(</span><span class="pln">ENV</span><span class="pun">[</span><span class="str">"HOME"</span><span class="pun">],</span><span class="pln"> </span><span class="str">".ssh"</span><span class="pun">,</span><span class="pln"> </span><span class="str">"id_rsa"</span><span class="pun">)]</span><span class="pln">
</span></pre>
<p>The only account on a default EC2 instance is root. You probably want to create a second user that is responsible for your application.</p>
<p>5: Copy your SSH public key to your EC2 node</p>
<pre class="prettyprint"><span class="pln">$ scp </span><span class="pun">-</span><span class="pln">i </span><span class="pun">~</span><span class="str">/my-ec2-keypair ~/</span><span class="pun">.</span><span class="pln">ssh</span><span class="pun">/</span><span class="pln">id_rsa</span><span class="pun">.</span><span class="pln">pub root@ec2</span><span class="pun">-</span><span class="lit">xxx</span><span class="pun">-</span><span class="lit">xxx</span><span class="pun">-</span><span class="lit">xxx</span><span class="pun">-xxx</span><span class="lit">.compute</span><span class="pun">-</span><span class="lit">1.amazonaws</span><span class="pun">.</span><span class="pln">com</span><span class="pun">:</span><span class="str">/root/</span><span class="pun">.</span><span class="pln">ssh</span><span class="pun">/</span><span class="pln">authorized_keys2</span></pre>
<p>NOTE the filename authorized_keys2 &#8211; not authorized_keys!!</p>
<p>6: Setup the EC2 node for Capistrano deployment.<br />
From your LOCAL machine, not the EC2 node:</p>
<pre class="prettyprint"><span class="pln">$ cap deploy</span><span class="pun">:</span><span class="pln">setup</span></pre>
<p>7: Finally, deploy your application</p>
<pre class="prettyprint"><span class="pln">$ cap deploy</span></pre>
<p>You will see lots of output and with this dummy application some of those will report errors/warnings. Don&#8217;t worry about that for now.</p>
<p>8: Check that the Deployment was successful<br />
Connect to the EC2 node with SSH the regular way, cd to the app directory and check that everything is there. If that is all working then you are ready to deploy a real application and add custom tasks for managing the database, restarting the server etc.</p>
<p>Bear in mind that Capistrano add new &#8216;releases&#8217; of your software in separate directories and symlinks the &#8216;current&#8217; directory to the latest. So the root of your deployed application is the &#8216;current&#8217; subdirectory.</p>
<p>Hope this will help you setting up your ec2 instance with capistrano.</p></div>


<!-- Begin SexyBookmarks Menu Code -->
<div class="sexy-bookmarks sexy-bookmarks-expand sexy-bookmarks-center">
<ul class="socials">
		<li class="sexy-delicious">
			<a href="http://del.icio.us/post?url=http://blog.bhushangahire.net/2010/02/17/setup-capistrano-to-deploy-rails-application-on-amazon-ec2-with-git/&amp;title=Setup+Capistrano+to+deploy+Rails+application+on+Amazon+EC2+with+Git" rel="nofollow" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="sexy-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://blog.bhushangahire.net/2010/02/17/setup-capistrano-to-deploy-rails-application-on-amazon-ec2-with-git/&amp;title=Setup+Capistrano+to+deploy+Rails+application+on+Amazon+EC2+with+Git" rel="nofollow" title="Digg this!">Digg this!</a>
		</li>
		<li class="sexy-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://blog.bhushangahire.net/2010/02/17/setup-capistrano-to-deploy-rails-application-on-amazon-ec2-with-git/&amp;title=Setup+Capistrano+to+deploy+Rails+application+on+Amazon+EC2+with+Git" rel="nofollow" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="sexy-technorati">
			<a href="http://technorati.com/faves?add=http://blog.bhushangahire.net/2010/02/17/setup-capistrano-to-deploy-rails-application-on-amazon-ec2-with-git/" rel="nofollow" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="sexy-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://blog.bhushangahire.net/2010/02/17/setup-capistrano-to-deploy-rails-application-on-amazon-ec2-with-git/&amp;t=Setup+Capistrano+to+deploy+Rails+application+on+Amazon+EC2+with+Git" rel="nofollow" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="sexy-twitter">
			<a href="http://twitter.com/home?status=Setup+Capistrano+to+deploy+Rails+application+on+Amazon+EC2+with+Git+-+http://tr.im/SU8k+(via+@bhushangahire)" rel="nofollow" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="sexy-linkedin">
			<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://blog.bhushangahire.net/2010/02/17/setup-capistrano-to-deploy-rails-application-on-amazon-ec2-with-git/&amp;title=Setup+Capistrano+to+deploy+Rails+application+on+Amazon+EC2+with+Git&amp;summary=1%3A%20Create%20a%20new%20Rails%20app%20-%20we%27ll%20call%20is%20%27deploytest%27%0D%0A%24%20rails%20deploytest%0D%0A%24%20cd%20deploytest%0D%0A2%3A%20Create%20a%20local%20Git%20repository%20for%20it%0D%0A%24%20git%20init%0D%0A%24%20git%20add%20%2A%0D%0A%24%20git%20commit%20-a%20-m%20%27initial%20commit%27%0D%0A%24%20git%20status%0D%0A3%3A%20Create%20a%20couple%20of%20Capistrano%20files%0D%0A%24%20capify%20.%0D%0A4%3A%20Edit%20config%2Fdeploy.rb%0D%0A%23%20The%20name%20o&amp;source=eXpand yOur cReativity" rel="nofollow" title="Share this on Linkedin">Share this on Linkedin</a>
		</li>
		<li class="sexy-tumblr">
			<a href="http://www.tumblr.com/share?v=3&amp;u=http%3A%2F%2Fblog.bhushangahire.net%2F2010%2F02%2F17%2Fsetup-capistrano-to-deploy-rails-application-on-amazon-ec2-with-git%2F&amp;t=Setup+Capistrano+to+deploy+Rails+application+on+Amazon+EC2+with+Git" rel="nofollow" title="Share this on Tumblr">Share this on Tumblr</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>
<!-- End SexyBookmarks Menu Code -->

<div style='clear:both'></div>]]></content:encoded>
			<wfw:commentRss>http://blog.bhushangahire.net/2010/02/17/setup-capistrano-to-deploy-rails-application-on-amazon-ec2-with-git/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Install Git on MAC Tiger (10.4.11)</title>
		<link>http://blog.bhushangahire.net/2009/04/14/install-git-on-mac-tiger-10411/</link>
		<comments>http://blog.bhushangahire.net/2009/04/14/install-git-on-mac-tiger-10411/#comments</comments>
		<pubDate>Tue, 14 Apr 2009 05:11:56 +0000</pubDate>
		<dc:creator>Bhushan Ahire</dc:creator>
				<category><![CDATA[MAC Tiger]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[tiger]]></category>

		<guid isPermaLink="false">http://blog.bhushangahire.net/?p=94</guid>
		<description><![CDATA[

I downloaded and compiled the latest Git version, 1.6.2.3 like so:

curl -O http://kernel.org/pub/software/scm/git/git-1.6.2.3.tar.gz
tar jxvf git-1.6.2.3.tar.gz
cd git-1.6.2.3
make prefix=/usr/local all
make prefix=/usr/local test &#38;&#38; echo $?
sudo make prefix=/usr/local install

When the compile was done, it gave me output like this:

!! You have installed git-* commands to new gitexecdir.
!! Old version git-* commands still remain in bindir.
!! Mixing two versions [...]]]></description>
			<content:encoded><![CDATA[<div class="fblike_button" style="margin: 10px 0;"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fblog.bhushangahire.net%2F2009%2F04%2F14%2Finstall-git-on-mac-tiger-10411%2F&amp;layout=standard&amp;show_faces=false&amp;width=450&amp;action=recommend&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:450px; height:25px"></iframe></div>
<div class="content">
<p>I downloaded and compiled the latest Git version, 1.6.2.3 like so:</p>
<div class="typocode">
<pre><code class="typocode_shell ">curl -O http://kernel.org/pub/software/scm/git/git-1.6.2.3.tar.gz
tar jxvf git-1.6.2.3.tar.gz
cd git-1.6.2.3
make prefix=/usr/local all
make prefix=/usr/local test &amp;&amp; echo $?
sudo make prefix=/usr/local install</code></pre>
</div>
<p>When the compile was done, it gave me output like this:</p>
<div class="typocode">
<pre><code class="typocode_shell ">!! You have installed git-* commands to new gitexecdir.
!! Old version git-* commands still remain in bindir.
!! Mixing two versions of Git will lead to problems.
!! Please remove old version commands in bindir now.</code></pre>
</div>
<p>I simply did:</p>
<div class="typocode">
<pre><code class="typocode_shell ">cd /usr/local/bin/
ls -latr | grep git</code></pre>
</div>
<p>Which gave me an ordered list of all the git binaries installed. The ones at the end all had today’s date on them, so I knew those were the new versions. The rest I could whack. The ones I could keep were <code>git-upload-pack</code>, <code>git-upload-archive</code>, <code>git-receive-pack</code>, <code>git</code>, <code>git-shell</code>, <code>git-cvsserver</code>, and <code>gitk</code>. The rest I removed like so:</p>
<div class="typocode">
<pre><code class="typocode_shell ">sudo rm git-var git-update-server-info git-unpack-file git-ssh-upload git-ssh-push git-ssh-pull git-ssh-fetch git-show-index git-send-pack git-peek-remote git-patch-id git-pack-redundant git-mktree git-mktag git-merge-tree git-merge-recursive git-merge-index git-local-fetch git-index-pack git-imap-send git-http-push git-http-fetch git-hash-object git-fetch-pack git-fast-import git-daemon git-convert-objects git-bisect git-write-tree git-whatchanged git-verify-tag git-verify-pack git-update-ref git-update-index git-unpack-objects git-tar-tree git-tag git-symbolic-ref git-svnimport git-svn git-submodule git-stripspace git-status git-stash git-show-ref git-show-branch git-show git-shortlog git-sh-setup git-send-email git-runstatus git-rm git-revert git-rev-parse git-rev-list git-reset git-rerere git-request-pull git-repo-config git-repack git-remote git-relink git-reflog git-rebase--interactive git-rebase git-read-tree git-quiltimport git-push git-pull git-prune-packed git-prune git-parse-remote git-pack-refs git-pack-objects git-name-rev git-mv git-mergetool git-merge-subtree git-merge-stupid git-merge-resolve git-merge-ours git-merge-one-file git-merge-octopus git-merge-file git-merge-base git-merge git-mailsplit git-mailinfo git-ls-tree git-ls-remote git-ls-files git-lost-found git-log git-instaweb git-init-db git-init git-gui git-grep git-get-tar-commit-id git-gc git-fsck-objects git-fsck git-format-patch git-for-each-ref git-fmt-merge-msg git-filter-branch git-fetch--tool git-fetch git-diff-tree git-diff-index git-diff-files git-diff git-describe git-cvsimport git-cvsexportcommit git-count-objects git-config git-commit-tree git-commit git-clone git-clean git-citool git-cherry-pick git-cherry git-checkout-index git-checkout git-check-ref-format git-check-attr git-cat-file git-bundle git-branch git-blame git-archive git-archimport git-apply git-annotate git-am git-add--interactive git-add gitjour</code></pre>
</div>
<p>Then I just had to go back and install the manpages for the new version like so:</p>
<div class="typocode">
<pre><code class="typocode_shell ">curl -O http://kernel.org/pub/software/scm/git/git-manpages-1.6.2.3.tar.bz2
sudo tar xjv -C /usr/local/man -f git-manpages-1.6.2.3.tar.bz2</code></pre>
</div>
<p>And, low and behold, I was now running git 1.6.2.3! </p></div>


<!-- Begin SexyBookmarks Menu Code -->
<div class="sexy-bookmarks sexy-bookmarks-expand sexy-bookmarks-center">
<ul class="socials">
		<li class="sexy-delicious">
			<a href="http://del.icio.us/post?url=http://blog.bhushangahire.net/2009/04/14/install-git-on-mac-tiger-10411/&amp;title=Install+Git+on+MAC+Tiger+%2810.4.11%29" rel="nofollow" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="sexy-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://blog.bhushangahire.net/2009/04/14/install-git-on-mac-tiger-10411/&amp;title=Install+Git+on+MAC+Tiger+%2810.4.11%29" rel="nofollow" title="Digg this!">Digg this!</a>
		</li>
		<li class="sexy-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://blog.bhushangahire.net/2009/04/14/install-git-on-mac-tiger-10411/&amp;title=Install+Git+on+MAC+Tiger+%2810.4.11%29" rel="nofollow" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="sexy-technorati">
			<a href="http://technorati.com/faves?add=http://blog.bhushangahire.net/2009/04/14/install-git-on-mac-tiger-10411/" rel="nofollow" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="sexy-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://blog.bhushangahire.net/2009/04/14/install-git-on-mac-tiger-10411/&amp;t=Install+Git+on+MAC+Tiger+%2810.4.11%29" rel="nofollow" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="sexy-twitter">
			<a href="http://twitter.com/home?status=Install+Git+on+MAC+Tiger+%2810.4.11%29+-+http://blog.bhushangahire.net/2009/04/14/install-git-on-mac-tiger-10411/+(via+@bhushangahire)" rel="nofollow" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="sexy-linkedin">
			<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://blog.bhushangahire.net/2009/04/14/install-git-on-mac-tiger-10411/&amp;title=Install+Git+on+MAC+Tiger+%2810.4.11%29&amp;summary=%0A%0AI%20downloaded%20and%20compiled%20the%20latest%20Git%20version%2C%201.6.2.3%20like%20so%3A%0A%0Acurl%20-O%20http%3A%2F%2Fkernel.org%2Fpub%2Fsoftware%2Fscm%2Fgit%2Fgit-1.6.2.3.tar.gz%0Atar%20jxvf%20git-1.6.2.3.tar.gz%0Acd%20git-1.6.2.3%0Amake%20prefix%3D%2Fusr%2Flocal%20all%0Amake%20prefix%3D%2Fusr%2Flocal%20test%20%26amp%3B%26amp%3B%20echo%20%24%3F%0Asudo%20make%20prefix%3D%2Fusr%2Flocal%20install%0A%0AWhen%20the%20c&amp;source=eXpand yOur cReativity" rel="nofollow" title="Share this on Linkedin">Share this on Linkedin</a>
		</li>
		<li class="sexy-tumblr">
			<a href="http://www.tumblr.com/share?v=3&amp;u=http%3A%2F%2Fblog.bhushangahire.net%2F2009%2F04%2F14%2Finstall-git-on-mac-tiger-10411%2F&amp;t=Install+Git+on+MAC+Tiger+%2810.4.11%29" rel="nofollow" title="Share this on Tumblr">Share this on Tumblr</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>
<!-- End SexyBookmarks Menu Code -->

<div style='clear:both'></div>]]></content:encoded>
			<wfw:commentRss>http://blog.bhushangahire.net/2009/04/14/install-git-on-mac-tiger-10411/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Keep either file in merge conflicts with git</title>
		<link>http://blog.bhushangahire.net/2009/02/26/keep-either-file-in-merge-conflicts-with-git/</link>
		<comments>http://blog.bhushangahire.net/2009/02/26/keep-either-file-in-merge-conflicts-with-git/#comments</comments>
		<pubDate>Thu, 26 Feb 2009 08:41:29 +0000</pubDate>
		<dc:creator>Bhushan Ahire</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[commit]]></category>
		<category><![CDATA[merge]]></category>

		<guid isPermaLink="false">http://blog.bhushangahire.net/?p=61</guid>
		<description><![CDATA[

So, the scenario is: you’re in the middle of a merge, and you want to keep one file or the other.
$ git merge master
  Auto-merged _layouts/default.html
  CONFLICT (content): Merge conflict in _layouts/default.html
  Auto-merged index.html
  CONFLICT (content): Merge conflict in index.html
  Automatic merge failed; fix conflicts and then commit the result.
There’s [...]]]></description>
			<content:encoded><![CDATA[<div class="fblike_button" style="margin: 10px 0;"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fblog.bhushangahire.net%2F2009%2F02%2F26%2Fkeep-either-file-in-merge-conflicts-with-git%2F&amp;layout=standard&amp;show_faces=false&amp;width=450&amp;action=recommend&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:450px; height:25px"></iframe></div>
<div id="post" class="grid_8 alpha content">
<p>So, the scenario is: you’re in the middle of a merge, and you want to keep one file or the other.</p>
<blockquote><p>$ git merge master<br />
  Auto-merged _layouts/default.html<br />
  CONFLICT (content): Merge conflict in _layouts/default.html<br />
  Auto-merged index.html<br />
  CONFLICT (content): Merge conflict in index.html<br />
  Automatic merge failed; fix conflicts and then commit the result.</p></blockquote>
<p>There’s two unmerged files here. According to the <a href="http://www.kernel.org/pub/software/scm/git/docs/git-checkout.html">git checkout</a> manpage, there’s a <code>--theirs</code> and <code>--ours</code> options on the command. The former will keep the version of the file that you merged in, and the other will keep the original one we had.</p>
<p>The following commands will keep the original file for index.html, and then use the merged in file only for _layouts/default.html.</p>
<blockquote><p>git checkout &#8211;ours index.html<br />
git checkout &#8211;theirs _layouts/default.html</p></blockquote>
<p>Sadly, these options are only in Git versions 1.6.1 and up. If you have an older version and don’t feel like upgrading, there’s ways to get around this. To emulate <code>--theirs</code>, we’d do:</p>
<blockquote><p>git reset &#8212; _layouts/default.html<br />
git checkout MERGE_HEAD &#8212; _layouts/default.html</p></blockquote>
<p>And for <code>--ours</code>:</p>
<blockquote><p>git reset &#8212; index.html<br />
git checkout ORIG_HEAD &#8212; index.html</p></blockquote>
<p>Of course, once you’ve got the conflicts worked out, <code>git add</code> whatever changes need to be added in, and <code>git commit</code> away. If you’ve run into other problems with merging that could possibly help out others, comment away!</p>
<p><br/><br />
referred from <a href='http://gitready.com/advanced/2009/02/25/keep-either-file-in-merge-conflicts.html'>http://gitready.com/advanced/2009/02/25/keep-either-file-in-merge-conflicts.html</a>
</div>


<!-- Begin SexyBookmarks Menu Code -->
<div class="sexy-bookmarks sexy-bookmarks-expand sexy-bookmarks-center">
<ul class="socials">
		<li class="sexy-delicious">
			<a href="http://del.icio.us/post?url=http://blog.bhushangahire.net/2009/02/26/keep-either-file-in-merge-conflicts-with-git/&amp;title=Keep+either+file+in+merge+conflicts+with+git" rel="nofollow" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="sexy-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://blog.bhushangahire.net/2009/02/26/keep-either-file-in-merge-conflicts-with-git/&amp;title=Keep+either+file+in+merge+conflicts+with+git" rel="nofollow" title="Digg this!">Digg this!</a>
		</li>
		<li class="sexy-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://blog.bhushangahire.net/2009/02/26/keep-either-file-in-merge-conflicts-with-git/&amp;title=Keep+either+file+in+merge+conflicts+with+git" rel="nofollow" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="sexy-technorati">
			<a href="http://technorati.com/faves?add=http://blog.bhushangahire.net/2009/02/26/keep-either-file-in-merge-conflicts-with-git/" rel="nofollow" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="sexy-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://blog.bhushangahire.net/2009/02/26/keep-either-file-in-merge-conflicts-with-git/&amp;t=Keep+either+file+in+merge+conflicts+with+git" rel="nofollow" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="sexy-twitter">
			<a href="http://twitter.com/home?status=Keep+either+file+in+merge+conflicts+with+git+-+http://tr.im/SURR+(via+@bhushangahire)" rel="nofollow" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="sexy-linkedin">
			<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://blog.bhushangahire.net/2009/02/26/keep-either-file-in-merge-conflicts-with-git/&amp;title=Keep+either+file+in+merge+conflicts+with+git&amp;summary=%0A%0ASo%2C%20the%20scenario%20is%3A%20you%E2%80%99re%20in%20the%20middle%20of%20a%20merge%2C%20and%20you%20want%20to%20keep%20one%20file%20or%20the%20other.%0A%24%20git%20merge%20master%0A%20%20Auto-merged%20_layouts%2Fdefault.html%0A%20%20CONFLICT%20%28content%29%3A%20Merge%20conflict%20in%20_layouts%2Fdefault.html%0A%20%20Auto-merged%20index.html%0A%20%20CONFLICT%20%28content%29%3A%20Merge%20conflict%20in%20index.html%0A%20%20Aut&amp;source=eXpand yOur cReativity" rel="nofollow" title="Share this on Linkedin">Share this on Linkedin</a>
		</li>
		<li class="sexy-tumblr">
			<a href="http://www.tumblr.com/share?v=3&amp;u=http%3A%2F%2Fblog.bhushangahire.net%2F2009%2F02%2F26%2Fkeep-either-file-in-merge-conflicts-with-git%2F&amp;t=Keep+either+file+in+merge+conflicts+with+git" rel="nofollow" title="Share this on Tumblr">Share this on Tumblr</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>
<!-- End SexyBookmarks Menu Code -->

<div style='clear:both'></div>]]></content:encoded>
			<wfw:commentRss>http://blog.bhushangahire.net/2009/02/26/keep-either-file-in-merge-conflicts-with-git/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Setting up a new remote git repository</title>
		<link>http://blog.bhushangahire.net/2009/02/19/setting-up-a-new-remote-git-repository/</link>
		<comments>http://blog.bhushangahire.net/2009/02/19/setting-up-a-new-remote-git-repository/#comments</comments>
		<pubDate>Thu, 19 Feb 2009 08:41:31 +0000</pubDate>
		<dc:creator>Bhushan Ahire</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[git repo]]></category>
		<category><![CDATA[server]]></category>

		<guid isPermaLink="false">http://blog.bhushangahire.net/?p=50</guid>
		<description><![CDATA[

For the impatient
Set up the new bare repo on the server:
$ ssh myserver.com
Welcome to myserver.com!
$ mkdir /var/git/myapp.git &#38;&#38; cd /var/git/myapp.git
$ git --bare init
Initialized empty Git repository in /var/git/myapp.git
$ exit
Bye!

Add the remote repository and push:
$ cd ~/Sites/myapp
$ git remote add origin ssh://myserver.com/var/git/myapp.git
$ git push origin master
Set the local master branch to track the remote branch.
Read further [...]]]></description>
			<content:encoded><![CDATA[<div class="fblike_button" style="margin: 10px 0;"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fblog.bhushangahire.net%2F2009%2F02%2F19%2Fsetting-up-a-new-remote-git-repository%2F&amp;layout=standard&amp;show_faces=false&amp;width=450&amp;action=recommend&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:450px; height:25px"></iframe></div>
<div class="content">
<h2>For the impatient</h2>
<p>Set up the new bare repo on the server:</p>
<pre><span class="keywords">$ ssh myserver.com</span>
Welcome to myserver.com!
<span class="keywords">$ mkdir /var/git/myapp.git &amp;&amp; cd /var/git/myapp.git</span>
<span class="keywords">$ git --bare init</span>
Initialized empty Git repository in /var/git/myapp.git
<span class="keywords">$ exit</span>
Bye!
</pre>
<p>Add the remote repository and push:</p>
<pre><span class="keywords">$ cd ~/Sites/myapp</span>
<span class="keywords">$ git remote add origin ssh://myserver.com/var/git/myapp.git</span>
<span class="keywords">$ git push origin master</span></pre>
<p>Set the local master branch to track the remote branch.</p>
<p>Read further for a step-by-step explanation of what’s going on.</p>
<h2>Pre-flight sanity check</h2>
<p>Setting up a remote repository is fairly simple but somewhat confusing at first. Firstly, let’s check out what remote repositories are being tracked in our git repo:</p>
<pre><span class="keywords">$ cd ~/Sites/myapp</span>
<span class="keywords">$ git remote</span></pre>
<p>None. Looking good. Now let’s list all the branches:</p>
<pre><span class="keywords">$ git branch -a</span>
* master
</pre>
<p>Just one branch, the master branch. Let’s have a look at <code>.git/config</code>:</p>
<pre><span class="keywords">$ cat .git/config</span>
[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true</pre>
<p>A pretty bare-minimum config file.</p>
<h2>Creating the bare remote repository</h2>
<p>Before we can push our local master branch to a remote repository we need to create the remote repository. To do this we’ll ssh in and create it on the server:</p>
<pre>
<span class="keywords">$ ssh myserver.com</span>
Welcome to myserver.com!
<span class="keywords">$ cd /var/git</span>
<span class="keywords">$ mkdir myapp.git</span>
<span class="keywords">$ cd myapp.git</span>
<span class="keywords">$ git --bare init</span>
Initialized empty Git repository in /var/git/myapp.git
<span class="keywords">$ exit</span>
Bye!
</pre>
<p>A short aside about what git means by <em>bare</em>: A default git repository assumes that you’ll be using it as your working directory, so git stores the actual bare repository files in a <code>.git</code> directory alongside all the project files. Remote repositories don’t need copies of the files on the filesystem unlike working copies, all they need are the deltas and binary what-nots of the repository itself. This is what “bare” means to git. Just the repository itself.</p>
<h2>Adding the remote repository to our local git repository configuration</h2>
<p>Now that we’ve created the remote repository we’ll add it to our local repository as a remote server called “origin” using <code>git remote add</code>, which is just a nicer way of updating our config file for us:</p>
<pre>
<span class="keywords">$ git remote add origin ssh://myserver.com/var/git/myapp.git</span></pre>
<p>Let’s see what it added to the config file:</p>
<pre>[core]
  repositoryformatversion = 0
  filemode = true
  bare = false
  logallrefupdates = true
[remote "origin"]
  url = ssh://myserver.com/var/git/myapp.git
  fetch = +refs/heads/*:refs/remotes/origin/*</pre>
<p>We now have a remote repository “origin” that will fetch all of it’s <code>refs/heads/*</code> branches and store them in our local repo in <code>refs/remotes/origin/*</code> when a <code>git fetch</code> is performed.</p>
<h2>Pushing to the remote repository</h2>
<p>The time has come to push our local master branch to the origin’s master branch. We do that using the <code>git push </code> command.</p>
<pre>
<span class="keywords">$ git push origin master</span>
updating 'refs/heads/master'
  from 0000000000000000000000000000000000000000
  to   b379203bc187c2926f44a71eca3f901321ea42c6
 Also local refs/remotes/origin/master
Generating pack...
Done counting 1374 objects.
Deltifying 1374 objects...
 100% (1374/1374) done
Writing 1374 objects...
 100% (1374/1374) done
Total 1374 (delta 89), reused 0 (delta 0)
refs/heads/master: 0000000000000000000000000000000000000000 -&gt; b379203bc187c2926f44a71eca3f901321ea42c6
</pre>
<p>and that’s all, folks. Further pushes can be done by repeating the <code>git push</code> command.</p>
<p>Now you can tell your co-conspirators to:</p>
<pre><span class="keywords">$ git clone ssh://myserver.com/var/git/myapp.git</span></pre>
<p>and push and pull to your heart’s content.</p>
<h2>Track the remote branch</h2>
<p>You can specify the default remote repository for pushing and pulling using git-branch’s track option. You’d normally do this by specifying the <code>--track</code> option when creating your local master branch, but as it already exists we’ll just update the config manually like so:</p>
<pre>[branch "master"]
  remote = origin
  merge = refs/heads/master
</pre>
<p>Now you can simply <code>git push</code> and <code>git pull</code>.</p>
<h2>Sharing the remote repository with the world</h2>
<p>If you want to set it up as a public repository be sure to check out the Git manual’s chapter on <a href="http://www.kernel.org/pub/software/scm/git/docs/user-manual.html#public-repositories">public git repositories</a>.</p>
<h2>Working with remote repository branches</h2>
<p><code>git remote show</code> is used to inspect a remote repository. It goes and checks the remote repository to see what branches have been added and removed since the last <code>git fetch</code>.</p>
<p>Doing a <code>git remote show</code> at the moment only shows us the remote repo’s master branch which we pushed earlier:</p>
<pre><span class="keywords">$ git remote show origin</span>
* remote origin
  URL: ssh://myserver.com/var/git/myapp.git
  Tracked remote branches
    master</pre>
<p>Let’s create a new local git repository and push to a new branch on the remote repository. We can then use <code>git remote show</code> to see the new remote branch, <code>git fetch</code> to mirror it into our local repo and <code>git checkout --track -b</code> to create a local branch to do some work on it.</p>
<p>We’ll start by creating a new local repo and pushing some code to a new branch in the remote repository.</p>
<pre><span class="keywords">$ mkdir /tmp/other-git</span>
<span class="keywords">$ cd /tmp/other-git</span>
<span class="keywords">$ git init</span>
Initialized empty Git repository in /tmp/other-git
<span class="keywords">$ git remote add origin ssh://myserver.com/var/git/myapp.git</span>
<span class="keywords">$ echo "Rails 2... woo" &gt; afile</span>
<span class="keywords">$ git add afile</span>
<span class="keywords">$ git commit -m "Added afile" </span>
Created initial commit 0ac9a74: Added afile
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 something
<span class="keywords">$ git push origin master:refs/heads/dev/rails-2</span>
updating 'refs/heads/rails-2' using 'refs/heads/master'
  from 0000000000000000000000000000000000000000
  to   0ac9a7457f4b21c9e058d4c54d262584bf35e528
 Also local refs/remotes/origin/rails-2
Generating pack...
Done counting 3 objects.
Deltifying 3 objects...
 100% (3/3) done
Writing 3 objects...
 100% (3/3) done
Total 3 (delta 0), reused 0 (delta 0)
Unpacking 3 objects...
 100% (3/3) done
refs/heads/rails-2: 0000000000000000000000000000000000000000 -&gt; 0ac9a7457f4b21c9e058d4c54d262584bf35e528
</pre>
<p>Now let’s switch back to our old git repository and see if it detects the new branch on the remote repository:</p>
<pre><span class="keywords">$ git remote show origin</span>
* remote origin
  URL: ssh://myserver.com/var/git/myapp.git
  New remote branches (next fetch will store in remotes/origin)
    dev/rails-2
  Tracked remote branches
    master
</pre>
<p>Let’s update our mirror of the remote repository by doing a <code>git fetch</code>:</p>
<pre><span class="keywords">$ git fetch</span>
* refs/remotes/origin/master: storing branch 'dev/rails-2' of ssh://myserver.com/var/git/myapp.git
  commit: b379203
<span class="keywords">$ git remote show origin</span>
* remote origin
  URL: ssh://myserver.com/var/git/myapp.git
  Tracked remote branches
    master
    dev/rails-2</pre>
<p>We should now be able to see this in a our list of remote branches:</p>
<pre><span class="keywords">$ git branch -a</span>
* master
origin/dev/rails-2
origin/master</pre>
<p>If we then wanted to do some work on this remote <code>dev/rails-2</code> branch we create a new local tracking branch like so:</p>
<pre><span class="keywords">$ git checkout --track -b dev/rails-2 origin/dev/rails-2</span>
Branch dev/rails-2 set up to track remote branch refs/remotes/origin/dev/rails-2.
Switched to a new branch "dev/rails-2"
</pre>
<p>To keep up-to-date and push new changesets we simply use <code>git push</code> and <code>git pull</code> when working in the local <code>dev/rails-2</code> branch.</p>
<p>Also notice, like we manually changed for master, <code>.git/config</code> has a new entry for this new tracking branch:</p>
<pre>[branch "dev/rails-2"]
  remote = origin
  merge = refs/heads/dev/rails-2
</pre>
</div>
<div class="content">Reference from <a href="http://toolmantim.com/articles/setting_up_a_new_remote_git_repository">http://toolmantim.com/articles/setting_up_a_new_remote_git_repository</a></div>


<!-- Begin SexyBookmarks Menu Code -->
<div class="sexy-bookmarks sexy-bookmarks-expand sexy-bookmarks-center">
<ul class="socials">
		<li class="sexy-delicious">
			<a href="http://del.icio.us/post?url=http://blog.bhushangahire.net/2009/02/19/setting-up-a-new-remote-git-repository/&amp;title=Setting+up+a+new+remote+git+repository" rel="nofollow" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="sexy-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://blog.bhushangahire.net/2009/02/19/setting-up-a-new-remote-git-repository/&amp;title=Setting+up+a+new+remote+git+repository" rel="nofollow" title="Digg this!">Digg this!</a>
		</li>
		<li class="sexy-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://blog.bhushangahire.net/2009/02/19/setting-up-a-new-remote-git-repository/&amp;title=Setting+up+a+new+remote+git+repository" rel="nofollow" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="sexy-technorati">
			<a href="http://technorati.com/faves?add=http://blog.bhushangahire.net/2009/02/19/setting-up-a-new-remote-git-repository/" rel="nofollow" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="sexy-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://blog.bhushangahire.net/2009/02/19/setting-up-a-new-remote-git-repository/&amp;t=Setting+up+a+new+remote+git+repository" rel="nofollow" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="sexy-twitter">
			<a href="http://twitter.com/home?status=Setting+up+a+new+remote+git+repository+-+http://tr.im/SURM+(via+@bhushangahire)" rel="nofollow" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="sexy-linkedin">
			<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://blog.bhushangahire.net/2009/02/19/setting-up-a-new-remote-git-repository/&amp;title=Setting+up+a+new+remote+git+repository&amp;summary=%0AFor%20the%20impatient%0ASet%20up%20the%20new%20bare%20repo%20on%20the%20server%3A%0A%24%20ssh%20myserver.com%0AWelcome%20to%20myserver.com%21%0A%24%20mkdir%20%2Fvar%2Fgit%2Fmyapp.git%20%26amp%3B%26amp%3B%20cd%20%2Fvar%2Fgit%2Fmyapp.git%0A%24%20git%20--bare%20init%0AInitialized%20empty%20Git%20repository%20in%20%2Fvar%2Fgit%2Fmyapp.git%0A%24%20exit%0ABye%21%0A%0AAdd%20the%20remote%20repository%20and%20push%3A%0A%24%20cd%20%7E%2FSites%2Fmy&amp;source=eXpand yOur cReativity" rel="nofollow" title="Share this on Linkedin">Share this on Linkedin</a>
		</li>
		<li class="sexy-tumblr">
			<a href="http://www.tumblr.com/share?v=3&amp;u=http%3A%2F%2Fblog.bhushangahire.net%2F2009%2F02%2F19%2Fsetting-up-a-new-remote-git-repository%2F&amp;t=Setting+up+a+new+remote+git+repository" rel="nofollow" title="Share this on Tumblr">Share this on Tumblr</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>
<!-- End SexyBookmarks Menu Code -->

<div style='clear:both'></div>]]></content:encoded>
			<wfw:commentRss>http://blog.bhushangahire.net/2009/02/19/setting-up-a-new-remote-git-repository/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
