<?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>expatiari expatria &#187; git</title>
	<atom:link href="http://genaud.net/tag/git/feed/" rel="self" type="application/rss+xml" />
	<link>http://genaud.net</link>
	<description>genaud.net</description>
	<lastBuildDate>Wed, 16 Nov 2011 05:51:15 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.4</generator>
		<item>
		<title>Git Publishing (rgit): Paranoia, Syndication, Transparency</title>
		<link>http://genaud.net/2008/11/git-publishing-rgit-paranoia-syndication-transparency/</link>
		<comments>http://genaud.net/2008/11/git-publishing-rgit-paranoia-syndication-transparency/#comments</comments>
		<pubDate>Mon, 24 Nov 2008 00:10:54 +0000</pubDate>
		<dc:creator>Alex</dc:creator>
				<category><![CDATA[geek]]></category>
		<category><![CDATA[dreamhost]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[remote]]></category>
		<category><![CDATA[shell script]]></category>
		<category><![CDATA[ssh]]></category>

		<guid isPermaLink="false">http://genaud.net/?p=250</guid>
		<description><![CDATA[     $   <a href="http://git.genaud.net/home/bin/rgit">rgit</a> HelloWorld        # public bare repo
     $   <a href="http://git.genaud.net/home/bin/rgit">rgit</a> -p WalledGarden   # private bare repo]]></description>
			<content:encoded><![CDATA[<p><center><code>
<pre>
$   <a href="http://git.genaud.net/home/bin/rgit">rgit</a> HelloWorld        #  public bare repo
$   <a href="http://git.genaud.net/home/bin/rgit">rgit</a> -p WalledGarden   # private bare repo
</pre>
<p></code></center></p>
<p>I&#8217;ve found myself using Git for nearly everything from organising my mp3, photo, and video collections, snapshot backups, synchronising devices, managing my love life, and walking my dog (just kidding about the videos). It&#8217;s fast, reliable, out of the way, and so damn useful, I wanted to find a way to create and publish a repository nearly instantly.</p>
<p>As I see it, there are only three use cases, all of which have only one user (namely me) with write permission. Those who insist on three additional use cases, and don&#8217;t mind the stench of centralised version control, might consider granting write permissions to multiple users via WebDAV. Though I argue in my upcoming rant entitled, <u>Tyranny of the proletariat: Beyond authoritarianism and democracy</u>, that multiple writers is symptomatic of an inefficient development model. The useful cases are: paranoia, syndication, and transparency.</p>
<p>In all cases, we create a repository remotely and clone it locally. In the paranoid case, the remote location is accessible only with encrypted transmission via SSH. The syndicate is publicly readable via Git over HTTP. The transparent case is web accessible and is also (in theory) publicly readable via Git.</p>
<p>Surprisingly enough, I&#8217;ve published the recipe for your coding pleasure (<a href="http://git.genaud.net/home/bin/rgit">rgit</a> from my <a href="http://git.genaud.net/home.git">home repo</a>). First, you&#8217;ll need to configure four variables. I source them from startup rc (.bash_profile), but you may find it more convenient to add them directly to the recipe:</p>
<p><code>
<pre>
export SSH_DOMAIN=user@domain.web
export WEB_DOMAIN=sub.domain.web
export PATH_TO_WEB='~/path/to/public/web'
export PATH_TO_PRIV='~/priv/git'
</pre>
<p></code></p>
<p>Then decide if you want a paranoid (bare, SSH only), syndicate (bare, Git readable over HTTP), or transparent remote repository (work tree, web browsable). The paranoid user must add the -p flag. A transparent repository is created with the -w flag. A syndicate repository, which is readable by anyone with Git, is the default.</p>
<p><code>
<pre>
$ <a href="http://git.genaud.net/home/bin/rgit">rgit</a> HelloWorld

Generating public Git bare repository accessible via:

http://sub.domain.web/HelloWorld.git

   ssh://user@domain.web/~/path/to/public/web/HelloWorld.git
Password:
Initialized empty Git repository in ~/path/to/public/web/HelloWorld.git/
Initialized empty Git repository in /home/user/local/HelloWorld/.git/
Created initial commit 5edcd54: Init with empty gitignore
 0 files changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 .gitignore
Pushing commit to remote repository via ssh
Password:
Counting objects: 3, done.
Writing objects: 100% (3/3), 228 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
To ssh://user@domain.web/~/path/to/public/web/HelloWorld.git
 * [new branch]      master -> master
Completed
</pre>
<p></code></p>
<p>There are a few things to note. First, any web directory can limit access with htaccess/htpasswd files as well as similar mechanisms within git. Second, you&#8217;ll probably want to figure out how to share your SSH key with the remote server, else you&#8217;ll be typing your password frequently. Third, both -wp flags are possible, though it doesn&#8217;t make a lot of sense to create a remote work tree to an otherwise inaccessible repository. Even if you intend to do work on the remote server, it is recommended (by <a href="http://kerneltrap.org/mailarchive/git/2007/3/18/241606">those</a> in the <a href="http://git.or.cz/gitwiki/GitFaq#head-b96f48bc9c925074be9f95c0fce69bcece5f6e73">know</a>) to work in a clone of a bare repository. Finally, the transparent case does not work as intended. While all repositories can be cloned over SSH and bare repositories over HTTP, I&#8217;ve run into some problems cloning a work repository over HTTP:</p>
<p><code>
<pre>
local$ git clone http://sub.domain.web/home home.http
Initialized empty Git repository in ~/home.http/.git/
warning: remote HEAD refers to nonexistent ref, unable to checkout.
</pre>
<p></code></p>
<p>The primary motivation for syndicating the recipe is to find a solution to the above problem. The fully transparent workaround is to syndicate a bare repository and clone a work tree, such as <a href="http://git.genaud.net/home.git">home.git</a> and <a href="http://git.genaud.net/home/">home/</a>. Perhaps this is just the case of publishing a web site. Transparency might be better handled by something like Trac, Git Web, or Cgit. Thoughts? Patches?</p>
<p>Inspiration:</p>
<ul>
<li><a href="http://casperfabricius.com/site/2008/09/21/keeping-git-repositories-on-dreamhost-using-ssh/">Casper Fabricius</a></li>
<li>Ben Lynn&#8217;s <a href="http://www-cs-students.stanford.edu/~blynn/gitmagic/ch06.html#id2547222">Git Magic</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://genaud.net/2008/11/git-publishing-rgit-paranoia-syndication-transparency/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ClearCase Globally, Git Locally</title>
		<link>http://genaud.net/2008/08/clearcase-globally-git-locally/</link>
		<comments>http://genaud.net/2008/08/clearcase-globally-git-locally/#comments</comments>
		<pubDate>Sat, 02 Aug 2008 15:26:26 +0000</pubDate>
		<dc:creator>Alex</dc:creator>
				<category><![CDATA[geek]]></category>
		<category><![CDATA[clearcase]]></category>
		<category><![CDATA[git]]></category>

		<guid isPermaLink="false">http://genaud.net/2008/08/clearcase-globally-git-locally/</guid>
		<description><![CDATA[Thanks ClearCase deserves all the credit for encouraging me to learn and love Git. Branching and merging is as fast and painless as listing changesets between any arbitrary branch or point in time. Did I say fast? No longer bound by ClearCase&#8217;s dictations and laborious linear progression, one can work off line, rollback, and experiment [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Thanks</strong><br />
<a href="http://www-306.ibm.com/software/awdtools/clearcase/">ClearCase</a> deserves all the credit for encouraging me to learn and love <a href="http://git.or.cz">Git</a>. Branching and merging is as fast and painless as listing changesets between any arbitrary branch or point in time. Did I say fast? No longer bound by ClearCase&#8217;s dictations and laborious linear progression, one can work off line, rollback, and experiment in multiple branches, travel into the past, and explore limitless parallel dimensions. While inspired by <a href="http://www-cs-students.stanford.edu/~blynn/gitmagic/ch03.html#id2543521">some</a> <a href="http://www.turbodad.com/2008/04/07/improving-clearcase-workflow-with-git/">other</a> <a href="http://www.littleredbat.net/mk/blog/story/63/">solutions</a>, I believe what follows is the cleanest imposition of a Git repository upon a ClearCase snapshot view.</p>
<p><strong>Summary</strong><br />
The following setup, namely a combined snapshot cloned locally, allows Git to track a ClearCase snapshot view without external functions (such as rsync), minimizing hijacks, untracked files, and encourages somewhat standard workflows with both ClearCase UCM and Git, without putting any limits on what can be done with a Git repository. This recipe assumes that the reader is proficient with the Unix/<a href="http://www.cygwin.com/">Cygwin</a> shell, Git, and ClearCase. In short, we will:</p>
<ul>
<li>Initialize a Git repository upon an existing pristine ClearCase snapshot view</li>
<li>Clone the snapshot as a Git repository</li>
<li>Track the master branch of the clone from the snapshot</li>
<li>Perform all ClearCase rebases, updates, checkins, and deliveries only in the snapshot</li>
<li>Work in branches of the Git clone</li>
<li>Pull between the master branches of the snapshot and clone repositories</li>
</ul>
<p><strong>Getting started</strong><br />
It is easiest to start with a fresh ClearCase snapshot view (what we&#8217;ll call snapshot) of which we&#8217;ll modify the <a href="http://www.kernel.org/pub/software/scm/git/docs/gitignore.html">.git/info/exclude</a> file (see below) to hide some of the ClearCase plumbing from Git. Then we <a href="http://www.kernel.org/pub/software/scm/git/docs/git-add.html">add</a> all the tracked content to a newly initialized git repository (which is one and the same as the ClearCase snapshot view), <a href="http://www.kernel.org/pub/software/scm/git/docs/git-clone.html">clone</a> it, and remote track the clone&#8217;s master branch. Now the clone (by default) and snapshot are tracking each other:</p>
<pre class="pre-sans-serif">
 $ cd snapshot
 $ <a href="http://www.kernel.org/pub/software/scm/git/docs/git-init.html">git init</a>
 $ cat >> <a href="http://www.kernel.org/pub/software/scm/git/docs/gitignore.html">.git/info/exclude</a>
.gitignore
view.dat
lost+found/
 $ <a href="http://www.kernel.org/pub/software/scm/git/docs/git-add.html">git add</a> .
 $ <a href="http://www.kernel.org/pub/software/scm/git/docs/git-commit.html">git commit</a> -m init
 $ <a href="http://www.kernel.org/pub/software/scm/git/docs/git-clone.html">git clone</a> -o snapshot . ../clone
 $ <i><a href="http://www.kernel.org/pub/software/scm/git/docs/git-clone.html">git remote</a> add -t master -m master clone ../clone</i>
</pre>
<p>(The last step, &#8216;git remote add&#8217;, when last tested does not seem to work. It&#8217;s not necessary, but if we could get it to work, it could be cool.)</p>
<p>We will want to keep the snapshot <a href="/uploads/2008/08/pristine/">pristine</a> (see below). It should only be used as a staging area between upstream rebases and checkins, and downstream pulls. As far as possible, all development, branches, and merging should occur in the work clone. The snapshot could just as easily be used by multiple people, say a team working on a common project. In that case, I might recommend another bare clone. But here, we&#8217;ll assume all Git repositories (including the overlapping ClearCase snapshot) are locally used by one developer.</p>
<p><strong>Git ignore</strong><br />
There are multiple ways to hide files from Git&#8217;s tracking view including <a href="http://www.kernel.org/pub/software/scm/git/docs/gitignore.html">.gitignore</a> files scattered anywhere within the directory structure. This may very well be appropriate within the clone development branches to hide build artifacts, temporary files, etc. There, in the clone, you should consider whether you want to share the .gitignore files (before committing them) or add .gitignore to the root .gitignore file, thus ignoring itself.</p>
<p>In the snapshot, however, I&#8217;ve chosen to use the <a href="http://www.kernel.org/pub/software/scm/git/docs/gitignore.html">.git/info/exclude</a> file instead because it is applied to the entire repository and is already hidden from Git&#8217;s tree. The snapshot has very different tracking requirements. We&#8217;ll want to filter out all of the Git and ClearCase plumbing such as view.dat, .vws, and any <a href="http://www.kernel.org/pub/software/scm/git/docs/gitignore.html">.gitignore</a> files that try to come upstream from the clone. However, we generally want to be aware of everything that passes through our snapshot. To that end, we want to ignore very little and consider all untracked files. A file untracked by one system indicates a new addition in the other or a deletion the other doesn&#8217;t yet know about. No files should ever be untracked by both ClearCase and Git in the snapshot.</p>
<p><strong>ClearCase update and rebase</strong><br />
I always run &#8220;Find modified files&#8221; from the ClearCase explorer before rebasing or delivering to ClearCase. Checkin, undo hijacks, etc, as appropriate to preserve a <a href="/uploads/2008/08/pristine/">pristine</a> snapshot. We&#8217;ll need to <a href="http://www.kernel.org/pub/software/scm/git/docs/git-add.html">add</a> (or <a href="http://www.kernel.org/pub/software/scm/git/docs/git-rm.html">remove</a>) upstream changes after updating or rebasing the snapshot. Modified files can be easily added to the Git index on <a href="http://www.kernel.org/pub/software/scm/git/docs/git-commit.html">commit</a> (with the -a flag).</p>
<pre class="pre-sans-serif">
# cd to snapshot
# rebase or update from ClearCase upstream
 $ <a href="http://www.kernel.org/pub/software/scm/git/docs/git-status.html">git status</a>
 $ <a href="http://www.kernel.org/pub/software/scm/git/docs/git-add.html">git add</a> (/some/files)
 $ <a href="http://www.kernel.org/pub/software/scm/git/docs/git-rm.html">git rm</a> (/old/files)
# repeat above until ClearCase changeset is in the index (no untracked files)
 $ <a href="http://www.kernel.org/pub/software/scm/git/docs/git-commit.html">git commit</a> -c "some comment"
</pre>
<p><strong>Downstream development</strong><br />
Assuming we&#8217;ve been developing in one or many branches within the clone, eventually some changes are bound to emerge interesting and stable enough to share with others. We&#8217;ll use the master branch of clone to stage our merges before delivering a pretty package upstream. First, we&#8217;ll need to be in sync with the snapshot. If snapshot is not <a href="/uploads/2008/08/pristine/">pristine</a>, we need to get it to that state. If there are commits in snapshot not found in the clone&#8217;s master, we should <a href="http://www.kernel.org/pub/software/scm/git/docs/git-pull.html">pull</a> (or <a href="http://www.kernel.org/pub/software/scm/git/docs/git-rebase.html">rebase</a>).</p>
<p>After clone&#8217;s master is equal to snapshot or contains a strict superset of changes, we can stage our changes in the master branch of clone. How we do that in the sidestream branches is completely up to you: rebase, pull, merge, squash, octopus, rebase -i. We commit a new feature into its own branch ready to be <a href="http://www.kernel.org/pub/software/scm/git/docs/git-merge.html">merged</a> and <a href="http://www.kernel.org/pub/software/scm/git/docs/git-pull.html">pulled</a> upstream. Our workflow might look something like this:</p>
<pre class="pre-sans-serif">
 $ cd ../clone
 $ diff -r . ../snapshot
(nothing)
 $ <a href="http://www.kernel.org/pub/software/scm/git/docs/git-checkout.html">git checkout</a> feature
 $ <a href="http://www.kernel.org/pub/software/scm/git/docs/git-rebase.html">git rebase</a> master
# test, work, test
 $ <a href="http://www.kernel.org/pub/software/scm/git/docs/git-checkout.html">git checkout</a> master
 $ <a href="http://www.kernel.org/pub/software/scm/git/docs/git-pull.html">git pull</a> feature
 $ <a href="http://www.kernel.org/pub/software/scm/git/docs/git-branch.html">git branch</a> -d feature
</pre>
<p><strong>Checkin to ClearCase</strong><br />
In the snapshot we&#8217;ll pull from clone&#8217;s master and deliver the changes upstream. We may have to manually add, remove, and checkout/in our changes to ClearCase. To help, we can <a href="http://www.kernel.org/pub/software/scm/git/docs/git-tag.html">tag</a> before pulling and display the file names as a difference along with the status (new, deleted, modified).</p>
<pre class="pre-sans-serif">
 $ cd ../snapshot
 $ <a href="http://www.kernel.org/pub/software/scm/git/docs/git-tag.html">git tag</a> before
 $ <i><a href="http://www.kernel.org/pub/software/scm/git/docs/git-pull.html">git pull</a> ../clone</i>
 $ <a href="http://www.kernel.org/pub/software/scm/git/docs/git-diff.html">git diff</a> --name-status before
</pre>
<p>(The &#8216;git remote add&#8217; could have been handy here)</p>
<p><strong>Automation</strong><br />
While the difference above could help us manually deliver upstream, the output of the last line above could very well be used in a script to deliver to ClearCase. Though I imagine procedures differ from environment to environment. I have not automated the ClearCase delivery myself, but here is a rough sketch:</p>
<pre class="pre-sans-serif">
 $ <a href="http://www.kernel.org/pub/software/scm/git/docs/git-diff.html">git diff</a> --name-status before > diff_before
 $ grep ^A diff_before | sed "s/^../cleartool mkelem /"
 $ grep ^M diff_before | sed "s/^../cleartool cc /"
 $ grep ^D diff_before | sed "s/^../cleartool rmname /"
 $ grep ^[ADM] diff_before | sed "s/^../cleartool ci /"
</pre>
<p><strong>Pristine</strong><br />
Similarly, the <a href="/uploads/2008/08/pristine/">pristine</a> state could be checked with &#8216;git status&#8217; and the ClearCase explorer. However, I&#8217;ve found the following commands helpful:</p>
<pre class="pre-sans-serif">
 $ find . -type f -writable | grep -v lost+found | grep -v view.dat
 $ find . -type f -name *keep
 $ find . -type d -name *unloaded
 $ <a href="http://www.kernel.org/pub/software/scm/git/docs/git-diff.html">git diff</a> --name-only HEAD
 $ <a href="http://www.kernel.org/pub/software/scm/git/docs/git-ls-files.html">git ls-files</a> --others | grep -v .git | grep -v lost+found | grep -v view.dat
 $ cleartool ls -recurse -view -short | grep -v lost+found
 $ cleartool lsco -me -recurse -short
 $ cleartool ls -recurse | grep "\[hijacked\]"
</pre>
<p>Or a script which simplifies the above. This may evolve into a full <a href="/uploads/2008/08/pristine/">git-clearcase</a> tool if it proves useful:</p>
<pre class="pre-sans-serif">
 $ <a href="/uploads/2008/08/pristine/">pristine</a>
Checking writable...    OK
Checking artifacts...   OK
Checking Git status...  OK
Checking CC Untrack...  OK
Checking CC Checkouts...OK
Checking CC Hijacks...  OK
</pre>
<pre>
$ <a href="/uploads/2008/08/pristine/">pristine</a> --help
usage: pristine [-[waguch]] [ dir... ]

   Flags: Check directories for...
       -w writable files (possibly hijacked)
       -a artifacts such as *.keep and *.unloaded
       -g Git status including untracked files
       -u ClearCase untracked files and directories
       -c ClearCase checked out files and directories
       -h ClearCase hijacked files and directories

   Note:
       The flags above are ordered considering
       speed and likelihood of failure (-w) to the
       slower operations (-ch).

       The ClearCase checks may be slower than other
       checks. -w is a reasonable substitute for -h
       although not technically the same (a file may
       be readonly and still hijacked)
</pre>
<p>Happy coding.</p>
]]></content:encoded>
			<wfw:commentRss>http://genaud.net/2008/08/clearcase-globally-git-locally/feed/</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
	</channel>
</rss>

