<?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>Sam Pierson&#039;s Blog &#187; git</title>
	<atom:link href="http://sampierson.com/blog/tag/git/feed/" rel="self" type="application/rss+xml" />
	<link>http://sampierson.com/blog</link>
	<description>Augmentation of an Imperfect Memory.</description>
	<lastBuildDate>Wed, 21 Jul 2010 01:41:32 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Replacing folders with submodules in Git</title>
		<link>http://sampierson.com/blog/software-development/replacing-folders-with-submodules-in-git/</link>
		<comments>http://sampierson.com/blog/software-development/replacing-folders-with-submodules-in-git/#comments</comments>
		<pubDate>Tue, 29 Sep 2009 03:15:18 +0000</pubDate>
		<dc:creator>sam</dc:creator>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[git]]></category>

		<guid isPermaLink="false">http://sampierson.com/blog/?p=629</guid>
		<description><![CDATA[I recently ran across the following problem:

Multiple people are developing on the same project, pushing commits into the same (e.g. GitHub) repo.
Developer A is working, and commits locally.
Developer B converts a folder into a Git submodule.
Developer A tries to git pull&#8230; BOOM &#8211; unresolveable conflict, local repo is left in a mess.

The problem is that [...]]]></description>
			<content:encoded><![CDATA[<p>I recently ran across the following problem:</p>
<ol>
<li>Multiple people are developing on the same project, pushing commits into the same (e.g. GitHub) repo.</li>
<li>Developer A is working, and commits locally.</li>
<li>Developer B converts a folder into a Git submodule.</li>
<li>Developer A tries to <em>git pull</em>&#8230; BOOM &#8211; unresolveable conflict, local repo is left in a mess.</li>
</ol>
<p>The problem is that because Developer A has a local commit, this forces a merge. <em>Git merge</em> has absolutely no idea how to resolve a conflict between a folder and a submodule.</p>
<p>To fix this, divide the merge into two parts, so you can separate the actions of removing the folder, and adding the submodule:</p>
<ul>
<li>Figure out the SHA of the commit where the folder was removed; let&#8217;s call it <em>abcdef</em> (as far as I am aware you cannot remove a folder and add in the submodule in 1 commit, so there will always be 2 commits here).</li>
<li>Reset your local repo back to HEAD</li>
<li>Merge up to that commit: git merge.</li>
<li>Merge the remaining commits</li>
</ul>
<p>i.e.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">&nbsp;
git reset <span style="color: #660033;">--hard</span> HEAD
git merge abcdef
git merge</pre></div></div>

<p>Alternatively, if only a few commits have been made and you are very lazy, you can do the following:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">&nbsp;
git merge origin~<span style="color: #000000;">5</span>
git merge origin~<span style="color: #000000;">4</span>
git merge origin~<span style="color: #000000;">3</span>
git merge origin~<span style="color: #000000;">2</span>
git merge origin~<span style="color: #000000;">1</span>
git merge</pre></div></div>

<p>Note that if you don&#8217;t have local changes, this issue does not occur as the fast-forward mechanism just applies all the commits in sequence and everything is cool.</p>
]]></content:encoded>
			<wfw:commentRss>http://sampierson.com/blog/software-development/replacing-folders-with-submodules-in-git/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>git feature branch</title>
		<link>http://sampierson.com/blog/software-development/git-feature-branch/</link>
		<comments>http://sampierson.com/blog/software-development/git-feature-branch/#comments</comments>
		<pubDate>Sun, 13 Sep 2009 22:17:56 +0000</pubDate>
		<dc:creator>sam</dc:creator>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[git]]></category>

		<guid isPermaLink="false">http://sampierson.com/blog/?p=598</guid>
		<description><![CDATA[It has been a while since I used git.  To remind me, and perhaps you:

&#160;
git checkout -b &#60;feature_name&#62;

Develop feature: code test commit rinse repeat.

&#160;
git checkout master
git merge &#60;feature_name&#62;
git branch -d &#60;feature_name&#62;

]]></description>
			<content:encoded><![CDATA[<p>It has been a while since I used git.  To remind me, and perhaps you:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">&nbsp;
git checkout <span style="color: #660033;">-b</span> <span style="color: #000000; font-weight: bold;">&lt;</span>feature_name<span style="color: #000000; font-weight: bold;">&gt;</span></pre></div></div>

<p>Develop feature: code test commit rinse repeat.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">&nbsp;
git checkout master
git merge <span style="color: #000000; font-weight: bold;">&lt;</span>feature_name<span style="color: #000000; font-weight: bold;">&gt;</span>
git branch <span style="color: #660033;">-d</span> <span style="color: #000000; font-weight: bold;">&lt;</span>feature_name<span style="color: #000000; font-weight: bold;">&gt;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://sampierson.com/blog/software-development/git-feature-branch/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>My Git cheat sheet</title>
		<link>http://sampierson.com/blog/software-development/git-cheat-sheet/</link>
		<comments>http://sampierson.com/blog/software-development/git-cheat-sheet/#comments</comments>
		<pubDate>Tue, 14 Apr 2009 14:20:09 +0000</pubDate>
		<dc:creator>sam</dc:creator>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[git]]></category>

		<guid isPermaLink="false">http://sampierson.com/blog/?p=512</guid>
		<description><![CDATA[Ultra-simple git usage:

# Initial 'checkout':
git clone &#60;remote-repository&#62;
&#160;
# Daily process:
cd &#60;local-repository&#62;
git pull
# Make some changes
git add &#60;changed files&#62;
git commit
git push

Setting up a shared git repo:

# Assuming you have an existing project in a git repo called &#34;./project&#34;:
mkdir project.git
cd project.git
git --bare init --shared
git --bare fetch ../project master:master
cd ..
scp -r project.git someserver:/some/shared/location
ssh server
sudo chgrp -R group_containing_all_developers /some/shared/location/project.git

Publish branch [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Ultra-simple git usage:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># Initial 'checkout':</span>
git clone <span style="color: #000000; font-weight: bold;">&lt;</span>remote-repository<span style="color: #000000; font-weight: bold;">&gt;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Daily process:</span>
<span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">&lt;</span>local-repository<span style="color: #000000; font-weight: bold;">&gt;</span>
git pull
<span style="color: #666666; font-style: italic;"># Make some changes</span>
git add <span style="color: #000000; font-weight: bold;">&lt;</span>changed files<span style="color: #000000; font-weight: bold;">&gt;</span>
git commit
git push</pre></div></div>

<p><strong>Setting up a shared git repo:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># Assuming you have an existing project in a git repo called &quot;./project&quot;:</span>
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> project.git
<span style="color: #7a0874; font-weight: bold;">cd</span> project.git
git <span style="color: #660033;">--bare</span> init <span style="color: #660033;">--shared</span>
git <span style="color: #660033;">--bare</span> fetch ..<span style="color: #000000; font-weight: bold;">/</span>project master:master
<span style="color: #7a0874; font-weight: bold;">cd</span> ..
<span style="color: #c20cb9; font-weight: bold;">scp</span> <span style="color: #660033;">-r</span> project.git someserver:<span style="color: #000000; font-weight: bold;">/</span>some<span style="color: #000000; font-weight: bold;">/</span>shared<span style="color: #000000; font-weight: bold;">/</span>location
<span style="color: #c20cb9; font-weight: bold;">ssh</span> server
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">chgrp</span> <span style="color: #660033;">-R</span> group_containing_all_developers <span style="color: #000000; font-weight: bold;">/</span>some<span style="color: #000000; font-weight: bold;">/</span>shared<span style="color: #000000; font-weight: bold;">/</span>location<span style="color: #000000; font-weight: bold;">/</span>project.git</pre></div></div>

<p><strong>Publish branch to remote:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># Create new branch locally:</span>
git branch <span style="color: #000000; font-weight: bold;">&lt;</span>branch name<span style="color: #000000; font-weight: bold;">&gt;</span>
<span style="color: #666666; font-style: italic;"># Push the branch to the remote repository:</span>
git push origin <span style="color: #000000; font-weight: bold;">&lt;</span>branch name<span style="color: #000000; font-weight: bold;">&gt;</span>
<span style="color: #666666; font-style: italic;"># Overwrite the local branch with a tracking version:</span>
git branch <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">&lt;</span>branch name<span style="color: #000000; font-weight: bold;">&gt;</span> origin<span style="color: #000000; font-weight: bold;">/&lt;</span>branch name<span style="color: #000000; font-weight: bold;">&gt;</span></pre></div></div>

<p><strong>Git submodules:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># Add a submodule:</span>
git submodule add <span style="color: #000000; font-weight: bold;">&lt;</span>repo<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">&lt;</span>path<span style="color: #000000; font-weight: bold;">&gt;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Cloning a repo with submodules:</span>
git clone <span style="color: #000000; font-weight: bold;">&lt;</span>repo<span style="color: #000000; font-weight: bold;">&gt;</span>
git submodule init
git submodule update
&nbsp;
<span style="color: #666666; font-style: italic;"># Updating a project with submodules</span>
git pull
git submodule update</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://sampierson.com/blog/software-development/git-cheat-sheet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>git submodules</title>
		<link>http://sampierson.com/blog/software-development/git-submodules/</link>
		<comments>http://sampierson.com/blog/software-development/git-submodules/#comments</comments>
		<pubDate>Mon, 13 Apr 2009 03:22:09 +0000</pubDate>
		<dc:creator>sam</dc:creator>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[git]]></category>

		<guid isPermaLink="false">http://sampierson.com/blog/?p=508</guid>
		<description><![CDATA[Add a submodule:

git submodule add &#60;repo&#62; &#60;path&#62;

Cloning a repo with submodules:

git clone &#60;repo&#62;
git submodule init
git submodule update

You have to run &#8216;git submodule update&#8217; after git pull if you want to update submodules, too.
Always publish the submodule change before publishing the change to the superproject that references it.
It&#8217;s not safe to run git submodule update if [...]]]></description>
			<content:encoded><![CDATA[<p>Add a submodule:</p>

<div class="wp_syntax"><div class="code"><pre class="foo" style="font-family:monospace;">git submodule add &lt;repo&gt; &lt;path&gt;</pre></div></div>

<p>Cloning a repo with submodules:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">git clone <span style="color:#006600; font-weight:bold;">&lt;</span>repo<span style="color:#006600; font-weight:bold;">&gt;</span>
git submodule init
git submodule update</pre></div></div>

<p>You have to run &#8216;git submodule update&#8217; after git pull if you want to update submodules, too.<br />
Always publish the submodule change before publishing the change to the superproject that references it.<br />
It&#8217;s not safe to run git submodule update if you&#8217;ve made and committed changes within a submodule without checking out a branch first. They will be silently overwritten.</p>
]]></content:encoded>
			<wfw:commentRss>http://sampierson.com/blog/software-development/git-submodules/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Git simple branching, published to remote</title>
		<link>http://sampierson.com/blog/software-development/git-simple-branching-published-to-remote/</link>
		<comments>http://sampierson.com/blog/software-development/git-simple-branching-published-to-remote/#comments</comments>
		<pubDate>Thu, 26 Mar 2009 05:08:16 +0000</pubDate>
		<dc:creator>sam</dc:creator>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[git]]></category>

		<guid isPermaLink="false">http://sampierson.com/blog/?p=496</guid>
		<description><![CDATA[Simple git branching technique in my environment (master copies of repos hosted on my remote server):
Create new branch locally:

$ git branch &#60;branch name&#62;

Push the branch to the remote repository:

$ git push origin &#60;branch name&#62;

Now for the wrinkle: as mentioned here, the local branch is not yet tracking the remote branch.  To fix this, overwrite [...]]]></description>
			<content:encoded><![CDATA[<p>Simple git branching technique in my environment (master copies of repos hosted on my remote server):</p>
<p>Create new branch locally:</p>

<div class="wp_syntax"><div class="code"><pre class="foo" style="font-family:monospace;">$ git branch &lt;branch name&gt;</pre></div></div>

<p>Push the branch to the remote repository:</p>

<div class="wp_syntax"><div class="code"><pre class="foo" style="font-family:monospace;">$ git push origin &lt;branch name&gt;</pre></div></div>

<p>Now for the wrinkle: as mentioned <a href="http://markelikalderon.com/blog/2008/08/26/pushing-and-tracking-remote-branches-with-git/">here</a>, the local branch is not yet tracking the remote branch.  To fix this, overwrite the local branch with a tracking version:</p>

<div class="wp_syntax"><div class="code"><pre class="foo" style="font-family:monospace;">$ $ git branch -f &lt;branch name&gt; origin/&lt;branch name&gt;</pre></div></div>

<p>To merge the branch back into the &#8216;trunk&#8217;:</p>

<div class="wp_syntax"><div class="code"><pre class="foo" style="font-family:monospace;">$ git checkout master
$ git merge &lt;branch name&gt;</pre></div></div>

<p>To delete the local and remote versions of the branch:</p>

<div class="wp_syntax"><div class="code"><pre class="foo" style="font-family:monospace;">$ git branch -d &lt;branch name&gt;
$ git push origin :&lt;branch name&gt;</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://sampierson.com/blog/software-development/git-simple-branching-published-to-remote/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ultra-simple git usage</title>
		<link>http://sampierson.com/blog/software-development/ultra-simple-git-usage/</link>
		<comments>http://sampierson.com/blog/software-development/ultra-simple-git-usage/#comments</comments>
		<pubDate>Fri, 19 Sep 2008 13:32:44 +0000</pubDate>
		<dc:creator>sam</dc:creator>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[git]]></category>

		<guid isPermaLink="false">http://sampierson.com/blog/?p=210</guid>
		<description><![CDATA[To access a shared repository (e.g. Subversion-style), using no branches, your work cycle will look like this:
Initial &#8216;checkout&#8217;:

git clone &#60;remote-repository&#62;

Daily process:

cd &#60;local-repository&#62;
git pull
# Make some changes
git add &#60;changed files&#62;
git commit
git push 

]]></description>
			<content:encoded><![CDATA[<p>To access a shared repository (e.g. Subversion-style), using no branches, your work cycle will look like this:</p>
<p>Initial &#8216;checkout&#8217;:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">git clone <span style="color: #000000; font-weight: bold;">&lt;</span>remote-repository<span style="color: #000000; font-weight: bold;">&gt;</span></pre></div></div>

<p>Daily process:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">&lt;</span>local-repository<span style="color: #000000; font-weight: bold;">&gt;</span>
git pull
<span style="color: #666666; font-style: italic;"># Make some changes</span>
git add <span style="color: #000000; font-weight: bold;">&lt;</span>changed files<span style="color: #000000; font-weight: bold;">&gt;</span>
git commit
git push </pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://sampierson.com/blog/software-development/ultra-simple-git-usage/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Setting up a shared (svn-like) git repository</title>
		<link>http://sampierson.com/blog/software-development/setting-up-a-shared-svn-like-git-repository/</link>
		<comments>http://sampierson.com/blog/software-development/setting-up-a-shared-svn-like-git-repository/#comments</comments>
		<pubDate>Fri, 19 Sep 2008 01:01:16 +0000</pubDate>
		<dc:creator>sam</dc:creator>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[git]]></category>

		<guid isPermaLink="false">http://sampierson.com/blog/?p=200</guid>
		<description><![CDATA[As described here&#8230;
Assuming you have an existing project in a git repo called &#8220;project&#8221;:

mkdir project.git
cd project.git
git --bare init --shared
git --bare fetch ../project master:master
cd ..
scp -r project.git someserver:/some/shared/location
ssh server
sudo chgrp -R group_containing_all_developers /some/shared/location/project.git

]]></description>
			<content:encoded><![CDATA[<p>As described <a href="http://www.kernel.org/pub/software/scm/git/docs/gitcvs-migration.html">here</a>&#8230;</p>
<p>Assuming you have an existing project in a git repo called &#8220;project&#8221;:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">mkdir</span> project.git
<span style="color: #7a0874; font-weight: bold;">cd</span> project.git
git <span style="color: #660033;">--bare</span> init <span style="color: #660033;">--shared</span>
git <span style="color: #660033;">--bare</span> fetch ..<span style="color: #000000; font-weight: bold;">/</span>project master:master
<span style="color: #7a0874; font-weight: bold;">cd</span> ..
<span style="color: #c20cb9; font-weight: bold;">scp</span> <span style="color: #660033;">-r</span> project.git someserver:<span style="color: #000000; font-weight: bold;">/</span>some<span style="color: #000000; font-weight: bold;">/</span>shared<span style="color: #000000; font-weight: bold;">/</span>location
<span style="color: #c20cb9; font-weight: bold;">ssh</span> server
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">chgrp</span> <span style="color: #660033;">-R</span> group_containing_all_developers <span style="color: #000000; font-weight: bold;">/</span>some<span style="color: #000000; font-weight: bold;">/</span>shared<span style="color: #000000; font-weight: bold;">/</span>location<span style="color: #000000; font-weight: bold;">/</span>project.git</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://sampierson.com/blog/software-development/setting-up-a-shared-svn-like-git-repository/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
