<?xml version="1.0" encoding="iso-8859-1"?>
<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/"
	xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule">

<channel>
	<title>Enquanto isso, na repartição...</title>
	<atom:link href="http://www.burocrata.org/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.burocrata.org/blog</link>
	<description>Relatos do maldito burocrata pigmeu</description>
	<lastBuildDate>Sun, 12 Jun 2011 19:17:40 +0000</lastBuildDate>
	<language>pt-br</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
<creativeCommons:license>http://creativecommons.org/licenses/by-nc-nd/2.5/br/</creativeCommons:license>		<item>
		<title>Exporting code to Git and tiding up its history</title>
		<link>http://www.burocrata.org/blog/archives/2011/06/12/396/exporting-code-to-git-and-tiding-up-its-history/</link>
		<comments>http://www.burocrata.org/blog/archives/2011/06/12/396/exporting-code-to-git-and-tiding-up-its-history/#comments</comments>
		<pubDate>Sun, 12 Jun 2011 19:16:04 +0000</pubDate>
		<dc:creator>MaCa</dc:creator>
				<category><![CDATA[DIY]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[github]]></category>
		<category><![CDATA[subversion]]></category>

		<guid isPermaLink="false">http://www.burocrata.org/blog/?p=396</guid>
		<description><![CDATA[Notice: The original guide is available as a GitHub gist at https://gist.github.com/1021890. Nevertheless, its content as on 2011-06-12, is presented bellow. Author: Tiago Alves Macambira [tmacam burocarata org] Licence:Creative Commons By-SA Table of Contents 1&#160;&#160;&#160;Introduction 1.1&#160;&#160;&#160;Objectives 2&#160;&#160;&#160;Starting things up 2.1&#160;&#160;&#160;Importing from the previous version control system 2.2&#160;&#160;&#160;Cloning a repository 3&#160;&#160;&#160;Pruning files from history 3.1&#160;&#160;&#160;Extract a [...]]]></description>
			<content:encoded><![CDATA[<div class="note" style="border: 1px solid black;">
<p class="admonition-title"><strong>Notice:</strong></p>
<p>The original guide is available as a GitHub gist at <a href="https://gist.github.com/1021890">https://gist.github.com/1021890</a>. Nevertheless, its content as on 2011-06-12, is presented bellow.</p>
</div>


<table class="docinfo" frame="void" rules="none">
<col class="docinfo-name" />
<col class="docinfo-content" />
<tbody valign="top">
<tr><th class="docinfo-name">Author:</th>
<td>Tiago Alves Macambira [tmacam burocarata org]</td></tr>
<tr class="field"><th class="docinfo-name">Licence:</th><td class="field-body">Creative Commons By-SA</td>
</tr>
</tbody>
</table>
<div class="contents topic" id="table-of-contents">
<p class="topic-title first">Table of Contents</p>
<ul class="auto-toc simple">
<li><a class="reference internal" href="#introduction" id="id1">1&nbsp;&nbsp;&nbsp;Introduction</a><ul class="auto-toc">
<li><a class="reference internal" href="#objectives" id="id2">1.1&nbsp;&nbsp;&nbsp;Objectives</a></li>
</ul>
</li>
<li><a class="reference internal" href="#starting-things-up" id="id3">2&nbsp;&nbsp;&nbsp;Starting things up</a><ul class="auto-toc">
<li><a class="reference internal" href="#importing-from-the-previous-version-control-system" id="id4">2.1&nbsp;&nbsp;&nbsp;Importing from the previous version control system</a></li>
<li><a class="reference internal" href="#cloning-a-repository" id="id5">2.2&nbsp;&nbsp;&nbsp;Cloning a repository</a></li>
</ul>
</li>
<li><a class="reference internal" href="#pruning-files-from-history" id="id6">3&nbsp;&nbsp;&nbsp;Pruning files from history</a><ul class="auto-toc">
<li><a class="reference internal" href="#extract-a-single-directory" id="id7">3.1&nbsp;&nbsp;&nbsp;Extract a single directory</a></li>
<li><a class="reference internal" href="#remove-files-and-directory-from-history-for-real" id="id8">3.2&nbsp;&nbsp;&nbsp;Remove files and directory from history for real</a></li>
</ul>
</li>
<li><a class="reference internal" href="#fixing-and-tiding-meta-data" id="id9">4&nbsp;&nbsp;&nbsp;Fixing and tiding meta-data</a><ul class="auto-toc">
<li><a class="reference internal" href="#fix-committer-information" id="id10">4.1&nbsp;&nbsp;&nbsp;Fix committer information</a></li>
<li><a class="reference internal" href="#fix-log-messages" id="id11">4.2&nbsp;&nbsp;&nbsp;Fix log messages</a></li>
</ul>
</li>
<li><a class="reference internal" href="#final-steps" id="id12">5&nbsp;&nbsp;&nbsp;Final steps</a><ul class="auto-toc">
<li><a class="reference internal" href="#shrink-your-repository" id="id13">5.1&nbsp;&nbsp;&nbsp;Shrink your repository.</a></li>
<li><a class="reference internal" href="#final-check" id="id14">5.2&nbsp;&nbsp;&nbsp;Final check</a></li>
<li><a class="reference internal" href="#export-it" id="id15">5.3&nbsp;&nbsp;&nbsp;Export it.</a></li>
</ul>
</li>
<li><a class="reference internal" href="#closing-remarks" id="id16">6&nbsp;&nbsp;&nbsp;Closing remarks</a><ul class="auto-toc">
<li><a class="reference internal" href="#some-missing-things-and-todos" id="id17">6.1&nbsp;&nbsp;&nbsp;Some missing things and TODOs</a></li>
</ul>
</li>
<li><a class="reference internal" href="#references" id="id18">7&nbsp;&nbsp;&nbsp;References</a></li>
</ul>
</div>
<div class="section" id="introduction">
<h3><a class="toc-backref" href="#id1">1&nbsp;&nbsp;&nbsp;Introduction</a></h3>
<p>So you have that awesome (or perhaps a not so awesome but at least not
shameful) project of yours that is just lingering around, collecting
dust and you thought: <em>"What if I released this code to the world? Would
I get famous? Would I became rich? Would I became the next Linus
Torvards?"</em>
Well, I would hate to disappoint you but the answer to those question is
probably <strong>no</strong>.</p>
<p>Nevertheless, be it for self promotion, for pure
generosity or just for the sake of having third-party maintained backup
of your code, releasing it to the world is a Good Thing (tm), and
something that would earn you some karma points -- and we are all short
on those, right?</p>
<p><em>"B-b-but"</em>, you say, <em>"my code is in a &lt;ancient, restraining, démodé or
plain untrendy by last standards&gt; Version Control System and I would
like to do what all the other cool kids are doing and export it as a</em>
<a class="reference external" href="http://git-scm.com/">Git</a> <em>repository in, say,</em> <a class="reference external" href="http://github.com">GitHub</a> <em>or... like... whatever..."</em></p>
<p>Fear no more, dear sheep, this guide is for you.</p>
<div class="section" id="objectives">
<h4><a class="toc-backref" href="#id2">1.1&nbsp;&nbsp;&nbsp;Objectives</a></h4>
<p>This short guide's purpose is to show you how to export a project from
another Version Control System -- or even from another <a class="reference external" href="http://git-scm.com/">Git</a> repository
-- such that its history is represented as cleanly and linearly as
possible.</p>
<p>Perhaps this project my be part of an old corporate project that you
just got approval to release as open source and, although you would like
it to retain as much history information as possible when you release
it, you still has a need (or obligation) to strip from it all and any
sensitive corporate information it has while releasing it. Maybe they are
in the form of sensitive log files that found their way into the
repository, or personal information (e-mails, usernames) that are in the
commit log messages.</p>
<p>So, it's not a matter of just removing, renaming, copying or moving
files around and committing -- as those files would still show up in
history, revealing the information you wanted to protect and taking
unnecessary repository space -- but of doing some serious cleaning and
re-structuring in the source code, its history and associated meta-data
-- whatever that is. This short guide is also about that.</p>
</div>
</div>
<div class="section" id="starting-things-up">
<h3><a class="toc-backref" href="#id3">2&nbsp;&nbsp;&nbsp;Starting things up</a></h3>
<div class="section" id="importing-from-the-previous-version-control-system">
<h4><a class="toc-backref" href="#id4">2.1&nbsp;&nbsp;&nbsp;Importing from the previous version control system</a></h4>
<p>So, the first thing you must do is import your project from the Version
Control System it is currently residing into a <a class="reference external" href="http://git-scm.com/">Git</a> repository.</p>
<p>If it is a subversion repository, <a class="reference external" href="http://www.kernel.org/pub/software/scm/git/docs/git-svn.html">git-svn</a> will do just fine.  If you are
using something else, say, perforce or CVS, similar tools exist to convert your
project and its history to <a class="reference external" href="http://git-scm.com/">Git</a>. You may need to do a intermediary conversion,
say, from CVS to subversion and from subversion to <a class="reference external" href="http://git-scm.com/">Git</a>.</p>
<p>For simplicity, last assume you have a project in a subversion
repository.  Let's also assume that the URL for this repository root is
<tt class="docutils literal"><span class="pre">svn+ssh://svn.example.tld/secure/repositories/meh_project/</span></tt> and that
your project (or the files you want to export) is located in
<tt class="docutils literal">aux/super_dupper_code</tt>.  The following command would fetch this
project and its history from subversion into a new <a class="reference external" href="http://git-scm.com/">Git</a> repository</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">git</span> <span style="color: #c20cb9; font-weight: bold;">svn</span> clone <span style="color: #660033;">--no-metadata</span> \
 <span style="color: #c20cb9; font-weight: bold;">svn</span>+<span style="color: #c20cb9; font-weight: bold;">ssh</span>:<span style="color: #000000; font-weight: bold;">//</span>svn.example.tld<span style="color: #000000; font-weight: bold;">/</span>secure<span style="color: #000000; font-weight: bold;">/</span>repositories<span style="color: #000000; font-weight: bold;">/</span>meh_project<span style="color: #000000; font-weight: bold;">/</span>aux<span style="color: #000000; font-weight: bold;">/</span>super_dupper_code</pre></div></div>



<p>First, notice that we are not converting the whole repository to <a class="reference external" href="http://git-scm.com/">Git</a>:
we are limiting as much as possible what we are importing from
subversion by grabbing just the code inside the <tt class="docutils literal">super_duper_code</tt>
directory. If, for some reason you had to import the whole repository
into <a class="reference external" href="http://git-scm.com/">Git</a>, do not worry, we will explain how to "prune" it later.</p>
<p>The import may bring some extra files that you may want to remove say, because
they are lame, for some legal reason or because they contain sensitive
information that it is not OK to share with the whole world. We will completely
remove them and their history from the <a class="reference external" href="http://git-scm.com/">Git</a> repository later, hopefully leaving
no trace of them whatsoever.</p>
<p>Since we have no interest in exporting any changes we make back to its original
subversion repository, we are using the <tt class="docutils literal"><span class="pre">--no-metadata</span></tt> option here. It will
also get rid of some extra <tt class="docutils literal"><span class="pre">git-svn-id:</span></tt> lines that <a class="reference external" href="http://www.kernel.org/pub/software/scm/git/docs/git-svn.html">git-svn</a> adds at the end
of every commit. Had we not used the <tt class="docutils literal"><span class="pre">--no-metadata</span></tt> option, we would
need to edit the commit messages to remove them. We will also show how
to modify commit meta-data (commit messages, commit authors etc) later.</p>
</div>
<div class="section" id="cloning-a-repository">
<h4><a class="toc-backref" href="#id5">2.2&nbsp;&nbsp;&nbsp;Cloning a repository</a></h4>
<p>"<em>We did not even got started and we are already cloning my repository?
What gives?</em>", you may ask.</p>
<p>Most of the steps we will give you in the following sections will alter your
<a class="reference external" href="http://git-scm.com/">Git</a> repository in semi-destructive ways, making heavy use of
<a class="reference external" href="http://www.kernel.org/pub/software/scm/git/docs/git-filter-branch.html">git-filter-branch</a>. I say semi-destructive because although <a class="reference external" href="http://www.kernel.org/pub/software/scm/git/docs/git-filter-branch.html">git-filter-branch</a>
almost always makes a copy of your repository's previous state, getting back to
this state may be complicated or, depending on the kind of modification
performed by <a class="reference external" href="http://www.kernel.org/pub/software/scm/git/docs/git-filter-branch.html">git-filter-branch</a>, impossible.</p>
<p>Additionally, it is of our interest to get rid of any "previous state" we get
and <em>properly</em> cloning a repository does the trick.</p>
<p>So, to avoid regrets and problems, let's first make a <em>proper</em> backup or clone
of your git repository:</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">git</span> clone <span style="color: #660033;">--no-hardlinks</span> <span style="color: #000000; font-weight: bold;">/</span>XYZ <span style="color: #000000; font-weight: bold;">/</span>ABC</pre></div></div>



<p>Using <tt class="docutils literal"><span class="pre">--no-hardlinks</span></tt> makes <a class="reference external" href="http://git-scm.com/">Git</a> create a clone by really coping the files
and not by using hard-links. This way the original repository won't share files and
metadata with its clone. See the man page if you have no idea of what I am
talking about.</p>
<p>Another way to get the same effect is by using a
<tt class="docutils literal"><span class="pre">file://path/to/your/git/repo</span></tt> URL, as documented  <a class="reference external" href="http://www.kernel.org/pub/software/scm/git/docs/git-filter-branch.html#_checklist_for_shrinking_a_repository">in the section
"Checklist for shrinking a repository" from git filter-branch manpage</a>:</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">git</span> clone  <span style="color: #c20cb9; font-weight: bold;">file</span>:<span style="color: #000000; font-weight: bold;">//</span>full<span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>XYZ <span style="color: #000000; font-weight: bold;">/</span>ABC</pre></div></div>



<p>With your backup done, let's move to destruct and reconstruct your <a class="reference external" href="http://git-scm.com/">Git</a> history.</p>
</div>
</div>
<div class="section" id="pruning-files-from-history">
<h3><a class="toc-backref" href="#id6">3&nbsp;&nbsp;&nbsp;Pruning files from history</a></h3>
<p>The import may have brought some extra files.  Now it's time to remove them and
prune the history we have in our Git repository.</p>
<p>Removing them from Git with a <tt class="docutils literal">git rm</tt>  will just remove them from the last
commit, but it will still leave traces and previous versions of those files in
our Git history -- not really what we wanted. We want to remove any trace of
them from the Git repository.</p>
<div class="section" id="extract-a-single-directory">
<h4><a class="toc-backref" href="#id7">3.1&nbsp;&nbsp;&nbsp;Extract a single directory</a></h4>
<p>Suppose you had to bring more files from your precious VCS than you originally
wanted. Say, you imported a whole CVS repository into Git and all you wanted
was a project that lives inside a particular subdirectory. In this case,
instead of removing all the other files and directories, it would be simpler
(and saner) to extract the target subdirectory from the whole mess.</p>
<p>Let's suppose your target subdirectory path is <tt class="docutils literal">projects/parsing/htmlparser</tt>.
The following commands would detach it this from your repository, leaving
nothing but it and its history:</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">git</span> filter-branch <span style="color: #660033;">--subdirectory-filter</span> projects<span style="color: #000000; font-weight: bold;">/</span>parsing<span style="color: #000000; font-weight: bold;">/</span>htmlparser HEAD <span style="color: #660033;">--</span> <span style="color: #660033;">--all</span>
<span style="color: #c20cb9; font-weight: bold;">git</span> reset <span style="color: #660033;">--hard</span>
<span style="color: #c20cb9; font-weight: bold;">git</span> <span style="color: #c20cb9; font-weight: bold;">gc</span> <span style="color: #660033;">--aggressive</span>
<span style="color: #c20cb9; font-weight: bold;">git</span> <span style="color: #c20cb9; font-weight: bold;">prune</span></pre></div></div>



<p>Notice that the first command ends in <tt class="docutils literal"><span class="pre">--</span> <span class="pre">--all</span></tt>. That's right: two dashes
space dash-dash-all. That will force Git to rewrite the history for all
branches and tags you have.</p>
<p>Now your repository consists only of the contents of
<tt class="docutils literal">projects/parsing/htmlparser</tt> and its history. Nothing more, nothing less.
Well, you may have mentioned other files in your commit messages but they will
not be there.</p>
</div>
<div class="section" id="remove-files-and-directory-from-history-for-real">
<h4><a class="toc-backref" href="#id8">3.2&nbsp;&nbsp;&nbsp;Remove files and directory from history for real</a></h4>
<p>So, by now we limited our history to the enclosing subdirectory holding all the
files we wanted. But there may still be some extra files that you may not want
to export because they are lame, for some legal reason or because they contain
sensitive information that it is not OK to share with the whole world. Let's
erase them from our repository and from its history altogether.</p>
<p>To remove a file or a directory named <tt class="docutils literal">path/to/SensitiveLogs</tt> from your repository,
run:</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">git</span> filter-branch <span style="color: #660033;">--index-filter</span> \
  <span style="color: #ff0000;">&quot;git rm -r -f --cached --ignore-unmatch path/to/SensitiveLogs&quot;</span> \
  <span style="color: #660033;">--prune-empty</span> HEAD <span style="color: #660033;">--</span> <span style="color: #660033;">--all</span></pre></div></div>



<p>Remove all files and directory you don't want exported using the command above.</p>
</div>
</div>
<div class="section" id="fixing-and-tiding-meta-data">
<h3><a class="toc-backref" href="#id9">4&nbsp;&nbsp;&nbsp;Fixing and tiding meta-data</a></h3>
<p>OK. As far as files and their history goes, your repository is clean and neat.
But during the process of converting your project and its history to Git, some
commit information such as commit author and commit messages may have been lost
or altered. Perhaps your commit messages mention sensitive data or informs your
previous and now invalid e-mail. Time to fix that.</p>
<div class="section" id="fix-committer-information">
<h4><a class="toc-backref" href="#id10">4.1&nbsp;&nbsp;&nbsp;Fix committer information</a></h4>
<p>Let's start this section with the committer information: its name and
e-mail address.</p>
<p>Once again, we will use <a class="reference external" href="http://www.kernel.org/pub/software/scm/git/docs/git-filter-branch.html">git-filter-branch</a> to edit our commit history.
This time, though, I will show two ways to accomplishing the same task.</p>
<p>The first is somewhat more elaborated as it shows how one can
programmatically alter the committer information. Say, for instance,
that except for a given committer, all other committers'
meta-data are OK. So you just want to alter commits related to this guy.
Let's say that this guy was you using a now invalid e-mail address. All
you have to do is alter only those commits where that old and invalid
e-mail is used. Here is how:</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">git</span> filter-branch <span style="color: #660033;">--commit-filter</span> <span style="color: #ff0000;">'
        if [ &quot;$GIT_COMMITTER_NAME&quot; = &quot;tmacam&quot; ];
        then
                GIT_AUTHOR_NAME=`git config --get user.name`;
                # or ...=&quot;Your (full) Name&quot;;
                GIT_AUTHOR_EMAIL=`git config --get user.email`;
                # or ...=&quot;your.email@example.tld&quot;;
                GIT_COMMITTER_NAME=$GIT_AUTHOR_NAME;
                GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL;
                git commit-tree &quot;$@&quot;;
        else
                git commit-tree &quot;$@&quot;;
        fi'</span> HEAD</pre></div></div>



<p>Notice that this command is assuming that you had already <a class="reference external" href="http://help.github.com/set-your-user-name-email-and-github-token/">configured
your identification information in git</a>.
If this is not your case, just replace those <tt class="docutils literal">git config <span class="pre">--get</span> xxxxxxx</tt>
commands for <tt class="docutils literal">"Your name"</tt> and <tt class="docutils literal">"&lt;your.email@example.tld&gt;"</tt>.</p>
<p>Anyway, as you can see, with some Bash programming kung-fu you can
create a pretty elaborated logic on how to replace or modify
committers' meta-data.</p>
<p>If all you want is to replace <strong>all</strong> committer information for a single
identity, the following one-liner would to the trick:</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">git</span> filter-branch <span style="color: #660033;">--env-filter</span> <span style="color: #ff0000;">'\
    GIT_AUTHOR_EMAIL=&quot;your.email@example.tld&quot;;\
    GIT_AUTHOR_NAME=&quot;Your (Full) Name&quot;;\
    export GIT_AUTHOR_EMAIL;\
    export GIT_AUTHOR_NAME;\
    export GIT_COMMITTER_EMAIL=${GIT_AUTHOR_EMAIL};\
    export GIT_COMMITTER_NAME=${GIT_AUTHOR_NAME};'</span></pre></div></div>



<p>And that's it. All commits will be attributed to "<em>Your (Full) Name
&lt;your.email@example.tld&gt;</em>".</p>
</div>
<div class="section" id="fix-log-messages">
<h4><a class="toc-backref" href="#id11">4.2&nbsp;&nbsp;&nbsp;Fix log messages</a></h4>
<p>Now time to tidy up those commit log messages. Guess what we will use
for this: <a class="reference external" href="http://www.kernel.org/pub/software/scm/git/docs/git-filter-branch.html">git-filter-branch</a> and its <tt class="docutils literal"><span class="pre">--msg-filter</span></tt> option. You can
perform almost any kind of editing with this duo: add lines, remove lines,
replace text.  Just give it the name of a program that will alter the
log messages and that's it.  The sky is the limit. <img src='http://www.burocrata.org/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>So, here is a short example of a command that will
remove all those nasty "<tt class="docutils literal"><span class="pre">git-svn-id:</span></tt>" lines that you got in your log
messages just because if did not read what I wrote in the <a class="reference internal" href="#importing-from-the-previous-version-control-system">Importing
from the previous version control system</a> section.:</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">git</span> filter-branch <span style="color: #660033;">--msg-filter</span> <span style="color: #ff0000;">' sed -e &quot;/^git-svn-id:/d&quot; '</span></pre></div></div>



</div>
</div>
<div class="section" id="final-steps">
<h3><a class="toc-backref" href="#id12">5&nbsp;&nbsp;&nbsp;Final steps</a></h3>
<div class="section" id="shrink-your-repository">
<h4><a class="toc-backref" href="#id13">5.1&nbsp;&nbsp;&nbsp;Shrink your repository.</a></h4>
<p>Now that your repository, its history, commits and their log messages
are all clean, tidy and free from shameful or sensitive information, is
time to do one last thing: shrink your repository.</p>
<p>See, as I said before in the <a class="reference internal" href="#cloning-a-repository">Cloning a repository</a> section,
<a class="reference external" href="http://www.kernel.org/pub/software/scm/git/docs/git-filter-branch.html">git-filter-branch</a> does store some copies of the state of the repository
as it goes modifying it. Now that we got here, we don't need or want
those copies. Time to get rid of them.</p>
<p>Go back to the <a class="reference internal" href="#cloning-a-repository">Cloning a repository</a> section and create another clone
of your repository using the procedures explained there. This should
give you a clean and neat clone to export/upload.</p>
</div>
<div class="section" id="final-check">
<h4><a class="toc-backref" href="#id14">5.2&nbsp;&nbsp;&nbsp;Final check</a></h4>
<p>Use a tool like <a class="reference external" href="http://gitx.frim.nl/">GitX</a> or <a class="reference external" href="http://www.kernel.org/pub/software/scm/git/docs/gitk.html">gitk</a> to analyse your history and look for any missing
or pending problem. Are there any empty branches you want to remove? Do the
commit messages look good? Does your project has any tag or branch that should not be
exported or that makes no sense in being exported? Remove them.</p>
<p>Fix those issues and shrink your repository once again. Yeah, your heard
me right: go clean your repo once again!</p>
<p>Good boy.</p>
</div>
<div class="section" id="export-it">
<h4><a class="toc-backref" href="#id15">5.3&nbsp;&nbsp;&nbsp;Export it.</a></h4>
<p>Well, time to export <img src='http://www.burocrata.org/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  Hooray! But export to where?</p>
<p>Well, there are countless options -- you could setup your own git
environment or use something like <a class="reference external" href="http://github.com">GitHub</a>. I strongly recommend you
taking the latter. Just head to <a class="reference external" href="http://github.com">GitHub</a>'s page, setup an account and
click on the "<tt class="docutils literal">New repository</tt>" button. Fill the presented form and
follow the steps presented there. And that's it <img src='http://www.burocrata.org/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  Your code now lives
in a public <a class="reference external" href="http://git-scm.com/">Git</a> repository and is there for the whole world to see.
Hope you are proud of if -- I really do. <img src='http://www.burocrata.org/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
</div>
</div>
<div class="section" id="closing-remarks">
<h3><a class="toc-backref" href="#id16">6&nbsp;&nbsp;&nbsp;Closing remarks</a></h3>
<div class="section" id="some-missing-things-and-todos">
<h4><a class="toc-backref" href="#id17">6.1&nbsp;&nbsp;&nbsp;Some missing things and TODOs</a></h4>
<p>I merely covered the steps I usually perform when I move code to <a class="reference external" href="http://github.com">GitHub</a>
from old subversion and CVS repositories of mine that used to hold stuff
from my masters and PhD -- so, there your got it, lame code <img src='http://www.burocrata.org/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>This means that there are tons of stuff I don't cover here. For
instance:</p>
<ul class="simple">
<li>How to add a copyright notice to all header files, from their
first commit and make them persist across all changes?</li>
<li>How to do the opposite: remove comments or copyright notices from files
and make this removal persist across changes to the files?</li>
<li>Edit the contents of some particular commit message.</li>
</ul>
<p>And so many other issues I don't have to deal with since I own the code
I am releasing. Or because I am lazy to fix everything. <img src='http://www.burocrata.org/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>Your mileage may vary <img src='http://www.burocrata.org/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
</div>
</div>
<div class="section" id="references">
<h3><a class="toc-backref" href="#id18">7&nbsp;&nbsp;&nbsp;References</a></h3>
<ul class="simple">
<li><a class="reference external" href="http://stackoverflow.com/questions/1072171/how-do-you-remove-an-invalid-remote-branch-reference-from-git">How do you Remove an Invalid Remote Branch Reference from Git? - Stack Overflow</a></li>
<li><a class="reference external" href="http://stackoverflow.com/questions/359424/detach-subdirectory-into-separate-git-repository">git filter branch - Detach subdirectory into separate Git repository - Stack Overflow</a></li>
<li><a class="reference external" href="http://stackoverflow.com/questions/750172/how-do-i-change-the-author-of-a-commit-in-git">version control - How do I change the author of a commit in git? - Stack Overflow</a></li>
<li><a class="reference external" href="http://help.github.com/removing-sensitive-data/">Help.GitHub - Removing sensitive data</a></li>
<li><a class="reference external" href="http://www.kernel.org/pub/software/scm/git/docs/git-filter-branch.html">git filter-branch manpage</a></li>
<li><a class="reference external" href="http://www.kernel.org/pub/software/scm/git/docs/git-svn.html">git svn manpage</a></li>
</ul>
</div>]]></content:encoded>
			<wfw:commentRss>http://www.burocrata.org/blog/archives/2011/06/12/396/exporting-code-to-git-and-tiding-up-its-history/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Teias e mais teias</title>
		<link>http://www.burocrata.org/blog/archives/2011/04/11/393/teias-e-mais-teias/</link>
		<comments>http://www.burocrata.org/blog/archives/2011/04/11/393/teias-e-mais-teias/#comments</comments>
		<pubDate>Tue, 12 Apr 2011 00:14:11 +0000</pubDate>
		<dc:creator>MaCa</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.burocrata.org/blog/?p=393</guid>
		<description><![CDATA[Sim, esse blog está entregue às baratas. Não, não há nada de interessante aqui, exceto que faço 30 anos em 4 dias. Grato.]]></description>
			<content:encoded><![CDATA[<p>Sim, esse blog está entregue às baratas.</p>
<p>Não, não há nada de interessante aqui, exceto que faço <a href="/30anos">30 anos</a> em 4 dias.</p>
<p>Grato.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.burocrata.org/blog/archives/2011/04/11/393/teias-e-mais-teias/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Private GIT repositories (on DreamHost)</title>
		<link>http://www.burocrata.org/blog/archives/2010/11/08/345/private-git-repositories-on-dreamhost/</link>
		<comments>http://www.burocrata.org/blog/archives/2010/11/08/345/private-git-repositories-on-dreamhost/#comments</comments>
		<pubDate>Tue, 09 Nov 2010 00:58:32 +0000</pubDate>
		<dc:creator>MaCa</dc:creator>
				<category><![CDATA[DIY]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Nerdocracia]]></category>
		<category><![CDATA[dreamhost]]></category>
		<category><![CDATA[english]]></category>
		<category><![CDATA[git]]></category>

		<guid isPermaLink="false">http://www.burocrata.org/blog/?p=345</guid>
		<description><![CDATA[This is yet another guide describing how to setup private HTTP-accessible Git repositories on Dreamhost using Git's git-http-backend (a.k.a git's Smart HTTP protocol). While similar guides can easily be found by the thousands in the Web (I've listed some of them in the Refereces section), I've found that some guides have outdated information or that the setup described in them could be improved. Thus, this guide tries to update, improve and consolidate the information dispersed in such sources.]]></description>
			<content:encoded><![CDATA[<p>This is yet another guide describing how to setup private HTTP-accessible Git repositories on Dreamhost using Git&#8217;s git-http-backend (a.k.a git&#8217;s Smart HTTP protocol). While similar guides can easily be found by the thousands in the Web (I&#8217;ve listed some of them in the Refereces section), I&#8217;ve found that some guides have outdated information or that the setup described in them could be improved. Thus, this guide tries to update, improve and consolidate the information dispersed in such sources.</p>
<p><span id="more-345"></span></p>

<div class="note" style="border: 1px solid black;">
<p class="admonition-title"><strong>Notice:</strong></p>
<p>the original guide is available at <a href="http://github.com/tmacam/private-git-on-dreamhost">http://github.com/tmacam/private-git-on-dreamhost</a>. Nevertheless, its content as on 2010-11-08, is presented bellow.</p></div>

<h3 class="title">Private GIT repositories (on DreamHost)</h3>
<table class="docinfo" frame="void" rules="none">
<col class="docinfo-name" />
<col class="docinfo-content" />
<tbody valign="top">
<tr><th class="docinfo-name">Author:</th>
<td>Tiago Alves Macambira</td></tr>
<tr class="field"><th class="docinfo-name">Licence:</th><td class="field-body">Creative Commons By-SA</td>
</tr>
</tbody>
</table>
<div class="contents topic" id="table-of-contents">
<p class="topic-title first">Table of Contents</p>
<ul class="auto-toc simple">
<li><a class="reference internal" href="#introduction" id="id10">1&nbsp;&nbsp;&nbsp;Introduction</a><ul class="auto-toc">
<li><a class="reference internal" href="#assumptions-and-requirements" id="id11">1.1&nbsp;&nbsp;&nbsp;Assumptions and requirements</a></li>
<li><a class="reference internal" href="#about-this-document" id="id12">1.2&nbsp;&nbsp;&nbsp;About this document</a></li>
</ul>
</li>
<li><a class="reference internal" href="#installation" id="id13">2&nbsp;&nbsp;&nbsp;Installation</a><ul class="auto-toc">
<li><a class="reference internal" href="#install-git" id="id14">2.1&nbsp;&nbsp;&nbsp;Install Git</a></li>
<li><a class="reference internal" href="#create-the-directory-where-your-repositories-will-live" id="id15">2.2&nbsp;&nbsp;&nbsp;Create the directory where your repositories will live</a></li>
<li><a class="reference internal" href="#setup-the-bare-repository-creation-script" id="id16">2.3&nbsp;&nbsp;&nbsp;Setup the bare repository creation script</a></li>
<li><a class="reference internal" href="#apache-setup" id="id17">2.4&nbsp;&nbsp;&nbsp;Apache Setup</a><ul class="auto-toc">
<li><a class="reference internal" href="#setup-your-htaccess" id="id18">2.4.1&nbsp;&nbsp;&nbsp;Setup your .htaccess</a></li>
<li><a class="reference internal" href="#setup-git-http-backend-for-your-repositories" id="id19">2.4.2&nbsp;&nbsp;&nbsp;Setup git-http-backend for your repositories</a></li>
<li><a class="reference internal" href="#password-protect-your-repository" id="id20">2.4.3&nbsp;&nbsp;&nbsp;Password-protect your repository</a></li>
<li><a class="reference internal" href="#setup-gitweb" id="id21">2.4.4&nbsp;&nbsp;&nbsp;Setup GitWeb</a><ul class="auto-toc">
<li><a class="reference internal" href="#retrieving-and-installing" id="id22">2.4.4.1&nbsp;&nbsp;&nbsp;Retrieving and installing</a></li>
<li><a class="reference internal" href="#setting-up-gitweb" id="id23">2.4.4.2&nbsp;&nbsp;&nbsp;Setting up GitWeb</a></li>
</ul>
</li>
</ul>
</li>
<li><a class="reference internal" href="#troubleshooting" id="id24">2.5&nbsp;&nbsp;&nbsp;Troubleshooting</a><ul class="auto-toc">
<li><a class="reference internal" href="#disable-authentication" id="id25">2.5.1&nbsp;&nbsp;&nbsp;Disable authentication</a></li>
<li><a class="reference internal" href="#use-info-cgi-script-to-check-cgi-script-s-environment" id="id26">2.5.2&nbsp;&nbsp;&nbsp;Use info.cgi script to check CGI script's environment</a></li>
<li><a class="reference internal" href="#check-the-server-logs" id="id27">2.5.3&nbsp;&nbsp;&nbsp;Check the server logs</a></li>
</ul>
</li>
</ul>
</li>
<li><a class="reference internal" href="#usage" id="id28">3&nbsp;&nbsp;&nbsp;Usage</a><ul class="auto-toc">
<li><a class="reference internal" href="#creating-new-bare-repositories" id="id29">3.1&nbsp;&nbsp;&nbsp;Creating new bare repositories</a></li>
<li><a class="reference internal" href="#cloning-an-empty-repository" id="id30">3.2&nbsp;&nbsp;&nbsp;Cloning an empty repository</a></li>
<li><a class="reference internal" href="#pushing-to-a-new-empty-repository" id="id31">3.3&nbsp;&nbsp;&nbsp;Pushing to a new empty repository</a></li>
</ul>
</li>
<li><a class="reference internal" href="#final-remarks" id="id32">4&nbsp;&nbsp;&nbsp;Final remarks</a></li>
<li><a class="reference internal" href="#todos" id="id33">5&nbsp;&nbsp;&nbsp;TODOs</a></li>
<li><a class="reference internal" href="#references" id="id34">6&nbsp;&nbsp;&nbsp;References</a></li>
</ul>
</div>
<div class="section" id="introduction">
<h3><a class="toc-backref" href="#id10">1&nbsp;&nbsp;&nbsp;Introduction</a></h3>
<p>This is <em>yet another</em> guide describing how to setup private
HTTP-accessible Git repositories on <a class="reference external" href="http://www.dreamhost.com">Dreamhost</a> using Git's
<tt class="docutils literal"><span class="pre">git-http-backend</span></tt> (a.k.a git's <a class="reference external" href="http://progit.org/2010/03/04/smart-http.html">Smart HTTP protocol</a>). While
similar guides can easily be found by the thousands in the Web (I've
listed some of them in the Refereces section), I've found that some
guides have outdated information or that the setup described in
them could be improved. Thus, this guide tries to update, improve and
consolidate the information dispersed in such sources.</p>
<p>Some might ask "Why on Earth would someone opt to create its own
private Git hosting solution while better offerings are available from
sites such as, let's say, <a class="reference external" href="http://github.com">GitHub</a>?" As the guy <a class="reference external" href="http://railstips.org/blog/archives/2008/11/23/gitn-your-shared-host-on/">from RailsTips
pointed out in one of his articles</a>, sometimes you don't need or
don't want to "share" a project with anyone but yourself and
paying for a <a class="reference external" href="http://github.com">GitHub</a>-like service might just not make sense.  If
that's your case, than this guide is for you.</p>
<p>While aimed at a <a class="reference external" href="http://www.dreamhost.com">Dreamhost</a>-hosted accounts and the environment such
accounts have as of 2010-10-17, I believe the process described here
can be used in other hosting providers as well.</p>
<p>It is important to highlight that one of the objectives of this guide
is to describe a process that:</p>
<ul class="simple">
<li>should be easy to perform by just renaming or editing this guide's
companion files and</li>
<li>once complete, can be easily be reused to generate other "collection
of repositories", with different URLs and passwords.</li>
</ul>
<div class="section" id="assumptions-and-requirements">
<h4><a class="toc-backref" href="#id11">1.1&nbsp;&nbsp;&nbsp;Assumptions and requirements</a></h4>
<ul>
<li><p class="first">No WebDav or SSH support is needed nor used for serving Git repositories.</p>
<p>Once again, the focus is on HTTP access using
<tt class="docutils literal"><span class="pre">git-http-backend</span></tt>. As for SSH, guides describing how to setup a
similar environment for SSH-accessible repositories can be found
easily on the web.</p>
</li>
<li><p class="first">Repositories will be password protected and available for both
reading and writting.</p>
<p>As we will explain latter, in the <a class="reference internal" href="#setup-git-http-backend-for-your-repositories">Setup git-http-backend for your
repositories</a> section, we will have to password-protect our
repositories in order to be able to <tt class="docutils literal">git push</tt> to them through HTTP.</p>
</li>
<li><p class="first">We will stick to a <a class="reference external" href="http://en.wikipedia.org/wiki/Don't_repeat_yourself">DRY</a> (Don't Repeat Yourself) philosophy.</p>
<p>Thus, we want configuration options to be repeated in as few places
as possible. We will use environment variables in Apache
configuration files to do this. If this makes you uncomfortable,
well, you can always manually spread configuration options all over
the place. <img src='http://www.burocrata.org/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  Your call.</p>
</li>
<li><p class="first">The web server being used is Apache.</p>
<p>Well, that is what <a class="reference external" href="http://www.dreamhost.com">Dreamhost</a> allows me to use so that is going to
be the focus of this guide. While it should not be that difficult to
port the settings here to something suitable for another web server,
describing how to do it is out of the scope of this guide.</p>
</li>
<li><p class="first">We are able to run CGI scripts.</p>
<p><a class="reference external" href="http://wiki.dreamhost.com/CGI">DreamHosts puts some restrictions</a>
on how a CGI script can be executed and the environment where it
runs. We will abide to those restrictions.</p>
</li>
</ul>
<ul>
<li><p class="first"><tt class="docutils literal">ScriptAlias</tt> is not allowed by the web server.</p>
<p>The instructions given in <a class="reference external" href="http://www.kernel.org/pub/software/scm/git/docs/git-http-backend.html">git-http-backend</a> manpage will not work as
they use <tt class="docutils literal">ScriptAlias</tt>. The idea is to use common CGI scripts and
<tt class="docutils literal">mod_rewrite</tt> instead, roughly following the ideas presented in
<a class="reference external" href="http://wiki.dreamhost.com/Git#Smart_HTTP">http://wiki.dreamhost.com/Git#Smart_HTTP</a> .</p>
</li>
<li><p class="first"><a class="reference external" href="http://wiki.dreamhost.com/Suexec">SuExec</a> is used to run CGI scripts.</p>
<p>Notice that, as stated in DreamHost page on CGI, <tt class="docutils literal">SuExec</tt> "<em>wipes out all
environment variables that don't start with HTTP_"</em>. All our
env. vars. will have this prefix.</p>
</li>
<li><p class="first">Your private git repositories will be accessible in a subpath of your
domain.</p>
<p>The idea is that your private git repos will be available in an
address such as <strong>http://www.example.tld/corporate-git/</strong>. Adapting
the instructions bellow so you can serve them from the root of a
domain of its own, say <strong>http://corporate-git.example.tld</strong> should
be fairly simple.</p>
</li>
</ul>
</div>
<div class="section" id="about-this-document">
<h4><a class="toc-backref" href="#id12">1.2&nbsp;&nbsp;&nbsp;About this document</a></h4>
<p>This document and its companion files are initially hosted on
<a class="reference external" href="http://github.com/tmacam/private-git-on-dreamhost">http://github.com/tmacam/private-git-on-dreamhost</a>.</p>
<p>The file <tt class="docutils literal">README.rst</tt> is generated from <tt class="docutils literal"><span class="pre">README-real.rst</span></tt>.  So, if
you plan on doing any updates or fixes, <tt class="docutils literal"><span class="pre">README-real.rst</span></tt> is the
file you ought to edit. Just run <tt class="docutils literal">make</tt> afterwards in order to get
<tt class="docutils literal">README.rst</tt> updated as well. This is done because I wanted to use
<a class="reference external" href="http://github.com">GitHub</a>'s automatic rendering of README files but I didn't want to
just paste the contents of the companion files in this <tt class="docutils literal">README.rst</tt>
and risk getting the Guide and files out of sync.  Unfortunately,
GitHub does not allow the use of RestructuredText's <tt class="docutils literal">include</tt>
directive, so I had to fake it -- and here is the reason why we have
<tt class="docutils literal"><span class="pre">README-real.rst</span></tt>.</p>
<p>This guide is distributed under the Creative Common BY-SA license while
companion files are distributed under a MIT License.</p>
</div>
</div>
<div class="section" id="installation">
<h3><a class="toc-backref" href="#id13">2&nbsp;&nbsp;&nbsp;Installation</a></h3>
<p>All the commands and instructions given bellow should be performed on
the machine in Dreamhost where your account is installed. So ssh to it
and let's start.</p>
<div class="section" id="install-git">
<h4><a class="toc-backref" href="#id14">2.1&nbsp;&nbsp;&nbsp;Install Git</a></h4>
<p>Well, this should probably be a non-issue since git comes
pre-installed on most Dreamhost machines. To verify it:</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">git</span> <span style="color: #660033;">--version</span>
<span style="color: #c20cb9; font-weight: bold;">git</span> version 1.7.1.1</pre></div></div>



<p>As you see, the box that serves my domain in dreamhost has git version
1.7.1.1 installed. <a class="reference external" href="http://progit.org/2010/03/04/smart-http.html">Anything greater than 1.6.6 shall do</a>.</p>
<p>If you don't have git installed in you box, have an old version or if
for some other reason your need to compile git, follow Craig's instructions in
<a class="reference external" href="http://craigjolicoeur.com/blog/hosting-git-repositories-on-dreamhost">Hosting Git Repositories on Dreamhost</a>.</p>
</div>
<div class="section" id="create-the-directory-where-your-repositories-will-live">
<h4><a class="toc-backref" href="#id15">2.2&nbsp;&nbsp;&nbsp;Create the directory where your repositories will live</a></h4>
<p>It should reside somewhere not accessible from the web or directly
served by the web server. We will tell Apache and <tt class="docutils literal"><span class="pre">git-http-backend</span></tt>
how to properly and securely serve those repositories latter. For now,
we want them protected from third parties.</p>
<p>Say we decided to store them in <tt class="docutils literal">~/private_repos/</tt>. We will refer to
this directly by <tt class="docutils literal">GIT_REPOS_ROOT</tt> in the rest of this guide. Create
this directory and protect it against filesystem access from others:</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">GIT_REPOS_ROOT</span>=<span style="color: #ff0000;">&quot;~/private_repos/&quot;</span>
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #800000;">${GIT_REPOS_ROOT}</span>
<span style="color: #c20cb9; font-weight: bold;">chmod</span> <span style="color: #000000;">711</span> <span style="color: #800000;">${GIT_REPOS_ROOT}</span></pre></div></div>



</div>
<div class="section" id="setup-the-bare-repository-creation-script">
<h4><a class="toc-backref" href="#id16">2.3&nbsp;&nbsp;&nbsp;Setup the bare repository creation script</a></h4>
<p>We will use the script <tt class="docutils literal">newgit.sh</tt>, presented bellow, to create new
repositories <a class="footnote-reference" href="#id7" id="id5">[1]</a> <a class="footnote-reference" href="#id8" id="id6">[2]</a> . Remember to modify
the value of the GIT_REPOS_ROOT variable in it to match our setup:</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># this script is based on code from the following blog post</span>
<span style="color: #666666; font-style: italic;"># http://arvinderkang.com/2010/08/25/hosting-git-repositories-on-dreamhost/</span>
<span style="color: #666666; font-style: italic;"># and http://gist.github.com/73622</span>
&nbsp;
&nbsp;
<span style="color: #000000; font-weight: bold;">set</span> <span style="color: #660033;">-e</span>
&nbsp;
&nbsp;
<span style="color: #666666; font-style: italic;"># Please, configure a default GIT_REPOS_ROOT to match your config</span>
<span style="color: #666666; font-style: italic;">#GIT_REPOS_ROOT=&quot;~/private_repos/&quot;</span>
&nbsp;
<span style="color: #007800;">DEFAULT_DESCRIPTION</span>=<span style="color: #ff0000;">'no description :('</span>
&nbsp;
&nbsp;
<span style="color: #666666; font-style: italic;"># describe how the script works</span>
usage<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #7a0874; font-weight: bold;">&#123;</span>
  <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Usage: $0 [ -h ] [ -r directory] [ -d description ] [ -n projectname ]&quot;</span>
  <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;&quot;</span>
  <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;If no projectname is given, the name of the parent folder will be used as project name.&quot;</span>
  <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;&quot;</span>
  <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;  -r directory   : (root) directory holding your git repositories&quot;</span>
  <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;  -d description : description for gitweb&quot;</span>
  <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;  -h             : print this screen&quot;</span>
  <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;  -n name        : name of the project (should end in .git)&quot;</span>
  <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;&quot;</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #007800;">DESCRIPTION</span>=<span style="color: #800000;">${DEFAULT_DESCRIPTION}</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># evaluate the options passed on the command line</span>
<span style="color: #000000; font-weight: bold;">while</span> <span style="color: #7a0874; font-weight: bold;">getopts</span> r:d:n:h option
<span style="color: #000000; font-weight: bold;">do</span>
  <span style="color: #000000; font-weight: bold;">case</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${option}</span>&quot;</span>
  <span style="color: #000000; font-weight: bold;">in</span>
    r<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #007800;">GIT_REPOS_ROOT</span>=<span style="color: #800000;">${OPTARG}</span><span style="color: #000000; font-weight: bold;">;;</span>
    d<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #007800;">DESCRIPTION</span>=<span style="color: #800000;">${OPTARG}</span><span style="color: #000000; font-weight: bold;">;;</span>
    n<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #007800;">REPONAME</span>=<span style="color: #800000;">${OPTARG}</span><span style="color: #000000; font-weight: bold;">;;</span>
    h<span style="color: #7a0874; font-weight: bold;">&#41;</span> usage
      <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span><span style="color: #000000; font-weight: bold;">;;</span>
  <span style="color: #000000; font-weight: bold;">esac</span>
<span style="color: #000000; font-weight: bold;">done</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># check if repositories directory is given and is accessible</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-z</span> <span style="color: #007800;">$GIT_REPOS_ROOT</span>  <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
    usage
    <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>
<span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-d</span> <span style="color: #007800;">$GIT_REPOS_ROOT</span>  <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;ERROR: '<span style="color: #007800;">${GIT_REPOS_ROOT}</span>' is not a directory&quot;</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;&quot;</span>
    usage
    <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
&nbsp;
<span style="color: #666666; font-style: italic;"># check if name of repository is given. if not, use folder name</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-z</span> <span style="color: #007800;">$REPONAME</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
  <span style="color: #007800;">REPONAME</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">basename</span> <span style="color: #007800;">$PWD</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Add .git at and if needed</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$REPONAME</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-q</span> <span style="color: #ff0000;">'\.git$'</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>; <span style="color: #000000; font-weight: bold;">then</span>
  <span style="color: #007800;">REPONAME</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${REPONAME}</span>.git&quot;</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
&nbsp;
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># Ready to go</span>
<span style="color: #666666; font-style: italic;">#</span>
&nbsp;
&nbsp;
<span style="color: #007800;">REP_DIR</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${GIT_REPOS_ROOT}</span>/<span style="color: #007800;">${REPONAME}</span>&quot;</span>
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #800000;">${REP_DIR}</span>
<span style="color: #7a0874; font-weight: bold;">pushd</span> <span style="color: #800000;">${REP_DIR}</span>
<span style="color: #c20cb9; font-weight: bold;">git</span> <span style="color: #660033;">--bare</span> init
<span style="color: #c20cb9; font-weight: bold;">git</span> <span style="color: #660033;">--bare</span> update-server-info
<span style="color: #c20cb9; font-weight: bold;">cp</span> hooks<span style="color: #000000; font-weight: bold;">/</span>post-update.sample hooks<span style="color: #000000; font-weight: bold;">/</span>post-update
<span style="color: #c20cb9; font-weight: bold;">chmod</span> a+x hooks<span style="color: #000000; font-weight: bold;">/</span>post-update
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$DESCRIPTION</span> <span style="color: #000000; font-weight: bold;">&gt;</span> description
<span style="color: #666666; font-style: italic;"># This mark the repository as exportable.</span>
<span style="color: #666666; font-style: italic;"># For more info refer to git-http-backend manpage</span>
<span style="color: #c20cb9; font-weight: bold;">touch</span> git-daemon-export-ok
<span style="color: #7a0874; font-weight: bold;">popd</span>
<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">0</span></pre></div></div>



<p>Move or copy this file to an appropriate path (say, your home
directory would be fine) and turn it into an executable:</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">chmod</span> u+x ~<span style="color: #000000; font-weight: bold;">/</span>newgit.sh</pre></div></div>



<table class="docutils footnote" frame="void" id="id7" rules="none">
<colgroup><col class="label" /><col /></colgroup>
<tbody valign="top">
<tr><td class="label"><a class="fn-backref" href="#id5">[1]</a></td><td>This script is based in <a class="reference external" href="http://gist.github.com/73622">http://gist.github.com/73622</a></td></tr>
</tbody>
</table>
<table class="docutils footnote" frame="void" id="id8" rules="none">
<colgroup><col class="label" /><col /></colgroup>
<tbody valign="top">
<tr><td class="label"><a class="fn-backref" href="#id6">[2]</a></td><td>Other guides prefer to use something similar wrapped as a Bash
function but I'd rather have it as a script</td></tr>
</tbody>
</table>
</div>
<div class="section" id="apache-setup">
<h4><a class="toc-backref" href="#id17">2.4&nbsp;&nbsp;&nbsp;Apache Setup</a></h4>
<p>Now, let's configure Apache to securely serve those repositories.</p>
<div class="section" id="setup-your-htaccess">
<h5><a class="toc-backref" href="#id18">2.4.1&nbsp;&nbsp;&nbsp;Setup your .htaccess</a></h5>
<p>As we stated in <a class="reference internal" href="#assumptions-and-requirements">Assumptions and requirements</a>, we want to serve our files from
<strong>http://www.example.tld/corporate-git/</strong>. So, go to the directory
holding your domain files (<tt class="docutils literal">~/www.example.tld</tt>, in our exemple),
create a <tt class="docutils literal"><span class="pre">corporate-git</span></tt> directory in it if it doesn't exist yet and create
a <tt class="docutils literal">.htaccess</tt> file in it:</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;">/</span>www.example.tld
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> corporate-git
<span style="color: #7a0874; font-weight: bold;">cd</span> corporate-git
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">GIT_WEB_DIR</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">pwd</span><span style="color: #000000; font-weight: bold;">`</span> <span style="color: #666666; font-style: italic;"># we will use it in latter steps</span>
<span style="color: #c20cb9; font-weight: bold;">touch</span> .htaccess
<span style="color: #c20cb9; font-weight: bold;">chmod</span> <span style="color: #000000;">644</span> .htaccess</pre></div></div>



<p>Now, edit this <tt class="docutils literal">.htaccess</tt> contents to match the text presented
bellow or just copy the contents of the file <tt class="docutils literal"><span class="pre">model-htaccess</span></tt> into
it and adapt it to match your config:</p>


<div class="wp_syntax"><div class="code"><pre class="apache" style="font-family:monospace;"><span style="color: #00007f;">Options</span> +<span style="color: #0000ff;">Indexes</span>
&nbsp;
<span style="color: #adadad; font-style: italic;"># GIT BEGIN ###########################################################</span>
&nbsp;
<span style="color: #00007f;">SetEnv</span> HTTP_GIT_PROJECT_ROOT /home/<span style="color: #00007f;">user</span>/private_repos/
<span style="color: #00007f;">SetEnv</span> HTTP_GITWEB_CONFIG /home/<span style="color: #00007f;">user</span>/private_repos/gitweb_config.perl
&nbsp;
&nbsp;
<span style="color: #00007f;">RewriteEngine</span> <span style="color: #0000ff;">On</span>
<span style="color: #00007f;">DirectoryIndex</span>  gitweb_wrapper.cgi
<span style="color: #adadad; font-style: italic;"># The following two rules can be used instead of DirectoryIndex</span>
<span style="color: #adadad; font-style: italic;">#RewriteRule ^$  gitweb_wrapper.cgi/ [L,E=SCRIPT_URL:/$1]</span>
<span style="color: #adadad; font-style: italic;">#RewriteRule ^([?].*)$ gitweb_wrapper.cgi/ [L,E=SCRIPT_URL:/$1]</span>
&nbsp;
<span style="color: #adadad; font-style: italic;"># Everything else that is not a file is forwarded to git-http-backend</span>
<span style="color: #00007f;">RewriteCond</span> %{REQUEST_FILENAME} !-f
<span style="color: #00007f;">RewriteRule</span> ^([^?].+)$ git-http-backend-private.cgi/$1
&nbsp;
&nbsp;
<span style="color: #adadad; font-style: italic;"># GIT END ############################################################</span>
&nbsp;
<span style="color: #adadad; font-style: italic;"># AUTHENTICATION BEGIN ###############################################</span>
<span style="color: #00007f;">AuthType</span> Digest
<span style="color: #00007f;">AuthName</span> <span style="color: #7f007f;">&quot;Private Git Repository Access&quot;</span>
<span style="color: #adadad; font-style: italic;"># UNCOMMENT THE LINE BELLOW FOR BETTER PERFORMANCE</span>
<span style="color: #adadad; font-style: italic;"># AuthDigestDomain /corporate-git/</span>
<span style="color: #00007f;">AuthUserFile</span> /home/<span style="color: #00007f;">user</span>/private_repos/.htpasswd
<span style="color: #00007f;">Require</span> valid-<span style="color: #00007f;">user</span>
<span style="color: #adadad; font-style: italic;"># AUTHENTICATION END  ################################################</span></pre></div></div>



<p>For now we will focus on the area between the <tt class="docutils literal"># GIT BEGIN</tt> and <tt class="docutils literal">#
GIT END</tt> blocks.  Modify <tt class="docutils literal">HTTP_GIT_PROJECT_ROOT</tt> to match you setup:
it should point to the <strong>full path</strong> where you store your private
repositories. Just expand the value of <tt class="docutils literal">GIT_REPOS_ROOT</tt> to get this
information:</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #800000;">${GIT_REPOS_ROOT}</span>; <span style="color: #7a0874; font-weight: bold;">pwd</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>user<span style="color: #000000; font-weight: bold;">/</span>private_repos<span style="color: #000000; font-weight: bold;">/</span></pre></div></div>



<p>So, in our example, <tt class="docutils literal">HTTP_GIT_PROJECT_ROOT</tt> value should be set to
<tt class="docutils literal">/home/user/private_repos/</tt>, as presented in the example above.</p>
</div>
<div class="section" id="setup-git-http-backend-for-your-repositories">
<h5><a class="toc-backref" href="#id19">2.4.2&nbsp;&nbsp;&nbsp;Setup git-http-backend for your repositories</a></h5>
<p>Not we will create a CGI script that will invoke
<tt class="docutils literal"><span class="pre">git-http-backend</span></tt>. In your <tt class="docutils literal">.htaccess</tt> this script is referred as
<tt class="docutils literal"><span class="pre">git-http-backend-private.cgi</span></tt>. Create it in the same directory
where you <tt class="docutils literal">.htaccess</tt> is by coping the one that comes with this guide
to that directory or by creating an empty file with the following
contents:</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span>
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">GIT_HTTP_EXPORT_ALL</span>=<span style="color: #000000;">1</span>
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">GIT_PROJECT_ROOT</span>=<span style="color: #800000;">${HTTP_GIT_PROJECT_ROOT:?HTTP_GIT_PROJECT_ROOT env. variable not set. Aborting.}</span>
<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>git-core<span style="color: #000000; font-weight: bold;">/</span>git-http-backend</pre></div></div>



<p>Turn it into an executable file:</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">chmod</span> <span style="color: #000000;">755</span> git-http-backend-private.cgi</pre></div></div>



<div class="attention">
<p class="first admonition-title">Attention!</p>
<p class="last">You may need to update the path to <tt class="docutils literal"><span class="pre">git-http-backend</span></tt> executable
if git was installed in a non-default location.</p>
</div>
<p>And that's it. No need to setup anything: all the settings this
scripts are passed to it through environment variables set by Apache
and defined in the <tt class="docutils literal">.htaccess</tt> file.</p>
<p>From this point on you should be able to create repositories from the
command line and
access them through HTTP, but they will be
<strong>read-only</strong>. As stated in <a class="reference external" href="http://www.kernel.org/pub/software/scm/git/docs/git-http-backend.html">git-http-backend</a> manpage, "<em>by default,
only the ``upload-pack`` service is enabled, which serves git ``fetch-pack``
and git ls-remote clients, which are invoked from ``git fetch``, ``git pull``,
and ``git clone``</em>". For <strong>write access</strong>, i.e., to be able to perform a
<tt class="docutils literal">git push</tt>, the <tt class="docutils literal"><span class="pre">receive-pack</span></tt> service is needed, and it <strong>is only
enabled when the client is authenticated</strong>.</p>
</div>
<div class="section" id="password-protect-your-repository">
<h5><a class="toc-backref" href="#id20">2.4.3&nbsp;&nbsp;&nbsp;Password-protect your repository</a></h5>
<p>We are almost set. Let's configure password protection for this whole
thing.  We will focus on the latter part of your <tt class="docutils literal">.htaccess</tt>, the one
between <tt class="docutils literal"># AUTHENTICATION BEGIN</tt> and <tt class="docutils literal"># AUTHENTICATION END</tt> that we
reproduce bellow:</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># AUTHENTICATION BEGIN ########################</span>
AuthType Digest
AuthName <span style="color: #ff0000;">&quot;Private Git Repository Access&quot;</span>
AuthUserFile <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>user<span style="color: #000000; font-weight: bold;">/</span>private_repos<span style="color: #000000; font-weight: bold;">/</span>.htpasswd
Require valid-user
<span style="color: #666666; font-style: italic;"># AUTHENTICATION END  #########################</span></pre></div></div>



<p>You will have to create the password file pointed by <tt class="docutils literal">AuthUserFile</tt>
and use the <tt class="docutils literal">htdigest</tt> tool to add a user to this file</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">touch</span> <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>user<span style="color: #000000; font-weight: bold;">/</span>private_repos<span style="color: #000000; font-weight: bold;">/</span>.htpasswd
htdigest <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>user<span style="color: #000000; font-weight: bold;">/</span>private_repos<span style="color: #000000; font-weight: bold;">/</span>.htpasswd <span style="color: #ff0000;">&quot;Private Git Repository Access&quot;</span> username</pre></div></div>



<p>You will be prompted for a password. And that's it.</p>
<p>Notice:</p>
<ul class="simple">
<li>we are using <a class="reference external" href="http://httpd.apache.org/docs/2.2/mod/mod_auth_digest.html#using">Digest Authentication</a>. It
is supposed to be more secure than plain authentication.</li>
<li>The password file should be keep in a place not directly accessible
from the web. Ideally it should not even be placed in the directory
to be served by <tt class="docutils literal"><span class="pre">git-http-backend</span></tt> but I'm lazy and I hope this
will be enough. <img src='http://www.burocrata.org/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </li>
<li>If you update the value of the <tt class="docutils literal">AuthName</tt> setting you <strong>must</strong>
also change the 2nd. parameter passed to <tt class="docutils literal">htdigest</tt>, i.e., the
<em>Realm</em>, as <a class="reference external" href="http://www.freebsdwiki.net/index.php/Apache,_Digest_Authentication">they must match</a>!
Odd, I know. But that's the way it is.</li>
</ul>
</div>
<div class="section" id="setup-gitweb">
<h5><a class="toc-backref" href="#id21">2.4.4&nbsp;&nbsp;&nbsp;Setup GitWeb</a></h5>
<p>If you followed this guide up to this point than you are able to use
your repositories with git with no major issues. But you will not be
able to browse them with a web browser, retrieve the list of
repositories you have, see diffs, commit messages nor nothing like
that. To make things better, let's install GitWeb, another CGI
interface that will provide a web interface that allows to do all
those things I just said you couldn't.</p>
<div class="note">
<p class="first admonition-title">Note</p>
<p class="last">Most of the content in this section comes from  Kang's <a class="reference external" href="http://arvinderkang.com/2010/08/25/hosting-git-repositories-on-dreamhost/">Hosting Git repositories on Dreamhost</a>.</p>
</div>
<div class="section" id="retrieving-and-installing">
<h6><a class="toc-backref" href="#id22">2.4.4.1&nbsp;&nbsp;&nbsp;Retrieving and installing</a></h6>
<p>GitWeb comes in the same source package as git itself. Unfortunately,
Dreamhost doesn't install it by default so we will have to install it
manually ourselves. Do your remember what is your git version? No?
Find it all:</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">git</span> <span style="color: #660033;">--version</span></pre></div></div>



<p>Go to <a class="reference external" href="http://git-scm.com/">git homepage</a> and download the corresponding source
package. In my example, in which my git version is 1.7.1.1, I would
need to grab the <tt class="docutils literal"><span class="pre">git-1.7.1.1.tar.gz</span></tt> source package:</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: #666666; font-style: italic;"># Yep, we will download it in our home directory</span>
<span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>www.kernel.org<span style="color: #000000; font-weight: bold;">/</span>pub<span style="color: #000000; font-weight: bold;">/</span>software<span style="color: #000000; font-weight: bold;">/</span>scm<span style="color: #000000; font-weight: bold;">/</span>git<span style="color: #000000; font-weight: bold;">/</span>git-1.7.1.1.tar.gz</pre></div></div>



<p>Unpack it, build GitWeb:</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">tar</span> zxvf git-1.7.1.1.tar.gz
<span style="color: #7a0874; font-weight: bold;">cd</span> git-1.7.1.1
<span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #007800;">prefix</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin gitweb<span style="color: #000000; font-weight: bold;">/</span>gitweb.cgi
<span style="color: #c20cb9; font-weight: bold;">rm</span> gitweb<span style="color: #000000; font-weight: bold;">/</span>gitweb.perl <span style="color: #666666; font-style: italic;"># we won't need it</span></pre></div></div>



<p>We will install it into <tt class="docutils literal">~/gitweb/</tt>:</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">GITWEB_INSTALL_DIR</span>=<span style="color: #ff0000;">&quot;~/gitweb&quot;</span>
<span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #660033;">-r</span> gitweb <span style="color: #800000;">${GITWEB_INSTALL_DIR}</span></pre></div></div>



<p>We are almost there.</p>
</div>
<div class="section" id="setting-up-gitweb">
<h6><a class="toc-backref" href="#id23">2.4.4.2&nbsp;&nbsp;&nbsp;Setting up GitWeb</a></h6>
<p>Now, copy all the GitWeb's media files into the directory
where your <tt class="docutils literal">.htaccess</tt> is:</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #800000;">${GITWEB_INSTALL_DIR}</span><span style="color: #000000; font-weight: bold;">/*</span>.<span style="color: #7a0874; font-weight: bold;">&#123;</span>css,png,js<span style="color: #7a0874; font-weight: bold;">&#125;</span> <span style="color: #800000;">${GIT_WEB_DIR}</span>
<span style="color: #666666; font-style: italic;"># in this example, GIT_WEB_DIR points</span>
<span style="color: #666666; font-style: italic;"># to ~/www.example.tld/corporate-git</span></pre></div></div>



<p>Get back to where your <tt class="docutils literal">.htaccess</tt> file is
(i.e. <tt class="docutils literal">GIT_WEB_DIR</tt>). We will create a wrapper CGI for
GitWeb. Just copy <tt class="docutils literal">gitweb_wrapper.cgi</tt> or create an empty file with
the contents bellow:</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">GITWEB_CONFIG</span>=<span style="color: #800000;">${HTTP_GITWEB_CONFIG:?HTTP_GITWEB_CONFIG env. variable not set. Aborting.}</span>
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">GIT_PROJECT_ROOT</span>=<span style="color: #800000;">${HTTP_GIT_PROJECT_ROOT:?HTTP_GIT_PROJECT_ROOT env. variable not set. Aborting.}</span>
&nbsp;
<span style="color: #800000;">${HOME}</span><span style="color: #000000; font-weight: bold;">/</span>gitweb<span style="color: #000000; font-weight: bold;">/</span>gitweb.cgi</pre></div></div>



<p>Turn it into an executable file:</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">chmod</span> <span style="color: #000000;">755</span> gitweb_wrapper.cgi</pre></div></div>



<div class="attention">
<p class="first admonition-title">Attention!</p>
<p class="last">If you have installed gitweb files in a different directory, you
will have to update this file to match the install location.</p>
</div>
<p>Once again, we are using settings stored in <tt class="docutils literal">.htaccess</tt> file and
passing them to a script using environment variables set by Apache. In
this case, we are informing the wrapper script where our repositories
are with <tt class="docutils literal">HTTP_GIT_PROJECT_ROOT</tt>, and informing it where GitWeb
configuration file is with <tt class="docutils literal">HTTP_GITWEB_CONFIG</tt>. The wrapper script,
in turn, will forward these informations to both GitWeb and to its
config file.</p>
<p>Now, let's create GitWeb configuration file. Just
copy <tt class="docutils literal">gitweb_config.perl</tt> provided with this guide to
<tt class="docutils literal"><span class="pre">${GIT_REPOS_ROOT}/gitweb_config.perl</span></tt> or create an empty file in
that path location with the following contents:</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># where is the git binary?</span>
<span style="color: #007800;">$GIT</span> = <span style="color: #ff0000;">&quot;/usr/bin/git&quot;</span>;
<span style="color: #666666; font-style: italic;"># where are our git project repositories?</span>
<span style="color: #007800;">$projectroot</span> = <span style="color: #007800;">$ENV</span><span style="color: #7a0874; font-weight: bold;">&#123;</span><span style="color: #ff0000;">'GIT_PROJECT_ROOT'</span><span style="color: #7a0874; font-weight: bold;">&#125;</span>;
<span style="color: #666666; font-style: italic;"># what do we call our projects in the gitweb UI?</span>
<span style="color: #007800;">$home_link_str</span> = <span style="color: #ff0000;">&quot;My Git Projects&quot;</span>;
<span style="color: #666666; font-style: italic;">#  where are the files we need for gitweb to display?</span>
<span style="color: #000000; font-weight: bold;">@</span>stylesheets = <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #ff0000;">&quot;gitweb.css&quot;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>;
<span style="color: #007800;">$logo</span> = <span style="color: #ff0000;">&quot;git-logo.png&quot;</span>;
<span style="color: #007800;">$favicon</span> = <span style="color: #ff0000;">&quot;/favicon.png&quot;</span>;
<span style="color: #666666; font-style: italic;"># what do we call this site?</span>
<span style="color: #007800;">$site_name</span> = <span style="color: #ff0000;">&quot;My Personal Git Repositories&quot;</span>;</pre></div></div>



<p>You can customize it a little bit, if you want, but the most important
setting, <tt class="docutils literal">$projectroot</tt>, is set to match the value of
<tt class="docutils literal">HTTP_GIT_PROJECT_ROOT</tt>, a env. var. set by Apache.</p>
<p>Notice that this file, <tt class="docutils literal">gitweb_config.perl</tt> is stored in the same
directory where your repositories are, in <tt class="docutils literal">${GIT_REPOS_ROOT}</tt>. If,
for some reason, you prefer to store it elsewhere, you will have to
update this information in the <tt class="docutils literal">.htaccess</tt> file.</p>
</div>
</div>
</div>
<div class="section" id="troubleshooting">
<h4><a class="toc-backref" href="#id24">2.5&nbsp;&nbsp;&nbsp;Troubleshooting</a></h4>
<p>So, something is not working as expected?</p>
<div class="section" id="disable-authentication">
<h5><a class="toc-backref" href="#id25">2.5.1&nbsp;&nbsp;&nbsp;Disable authentication</a></h5>
<p>Comment out the authentication code. This will ease your "debugging"
process.</p>
<p>Remember to uncomment it latter.</p>
</div>
<div class="section" id="use-info-cgi-script-to-check-cgi-script-s-environment">
<h5><a class="toc-backref" href="#id26">2.5.2&nbsp;&nbsp;&nbsp;Use info.cgi script to check CGI script's environment</a></h5>
<p>A nice way to check if there is something really wrong with your setup
is to use the <tt class="docutils literal">info.cgi</tt>, whose code is presented bellow. This
script is only a minor modification to the one presented in <a class="reference external" href="http://wiki.dreamhost.com/CGI">Dreamhost
wiki page on CGI</a> and allows your to do verify if you are able to
execute CGI scrips and what settings Apache is passing to the other
CGI scripts we use here.</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># disable filename globbing</span>
<span style="color: #000000; font-weight: bold;">set</span> <span style="color: #660033;">-f</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Content-type: text/plain; charset=iso-8859-1&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">echo</span> CGI<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">1.0</span> <span style="color: #7a0874; font-weight: bold;">test</span> script report:
<span style="color: #7a0874; font-weight: bold;">echo</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">echo</span> argc is <span style="color: #007800;">$#</span>. argv is <span style="color: #ff0000;">&quot;$*&quot;</span>.
<span style="color: #7a0874; font-weight: bold;">echo</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">echo</span> SERVER_SOFTWARE = <span style="color: #007800;">$SERVER_SOFTWARE</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> SERVER_NAME = <span style="color: #007800;">$SERVER_NAME</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> GATEWAY_INTERFACE = <span style="color: #007800;">$GATEWAY_INTERFACE</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> SERVER_PROTOCOL = <span style="color: #007800;">$SERVER_PROTOCOL</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> SERVER_PORT = <span style="color: #007800;">$SERVER_PORT</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> REQUEST_METHOD = <span style="color: #007800;">$REQUEST_METHOD</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> HTTP_ACCEPT = <span style="color: #ff0000;">&quot;<span style="color: #007800;">$HTTP_ACCEPT</span>&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> PATH_INFO = <span style="color: #ff0000;">&quot;<span style="color: #007800;">$PATH_INFO</span>&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> PATH_TRANSLATED = <span style="color: #ff0000;">&quot;<span style="color: #007800;">$PATH_TRANSLATED</span>&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> SCRIPT_NAME = <span style="color: #ff0000;">&quot;<span style="color: #007800;">$SCRIPT_NAME</span>&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> QUERY_STRING = <span style="color: #ff0000;">&quot;<span style="color: #007800;">$QUERY_STRING</span>&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> REMOTE_HOST = <span style="color: #007800;">$REMOTE_HOST</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> REMOTE_ADDR = <span style="color: #007800;">$REMOTE_ADDR</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> REMOTE_USER = <span style="color: #007800;">$REMOTE_USER</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> AUTH_TYPE = <span style="color: #007800;">$AUTH_TYPE</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> CONTENT_TYPE = <span style="color: #007800;">$CONTENT_TYPE</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> CONTENT_LENGTH = <span style="color: #007800;">$CONTENT_LENGTH</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> HTTP_GIT_PROJECT_ROOT = <span style="color: #007800;">$HTTP_GIT_PROJECT_ROOT</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> HTTP_GITWEB_CONFIG = <span style="color: #007800;">$HTTP_GITWEB_CONFIG</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">0</span></pre></div></div>



<p>Copy it to <tt class="docutils literal">GIT_WEB_DIR</tt>, turn it into an executable script
(<tt class="docutils literal">chmod 755 ...</tt>) and point your browser to it ( That would be
<tt class="docutils literal"><span class="pre">http://www.example.tld/corporate-git/</span></tt> in our example).</p>
</div>
<div class="section" id="check-the-server-logs">
<h5><a class="toc-backref" href="#id27">2.5.3&nbsp;&nbsp;&nbsp;Check the server logs</a></h5>
<p>We are listing this as a last step but that's probably the fist place
where you should have looked for clues: your server logs.</p>
<p>For example:</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>Mon Oct <span style="color: #000000;">25</span> <span style="color: #000000;">18</span>:<span style="color: #000000;">30</span>:<span style="color: #000000;">28</span> <span style="color: #000000;">2010</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>error<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>client 150.164.3.192<span style="color: #7a0874; font-weight: bold;">&#93;</span> Service not enabled: <span style="color: #ff0000;">'receive-pack'</span></pre></div></div>



<p>This message says that 'receive-pack' was not enable -- probably
because you are trying to push to a repository and authentication was
disabled. As we explained in <a class="reference internal" href="#setup-git-http-backend-for-your-repositories">Setup git-http-backend for your
repositories</a>, you <strong>must</strong> use authentication to be able to write
(<em>push</em>) to repositories using git-http-backend.</p>
<p>This one should be pretty obvious:</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Digest: user username: password mismatch: <span style="color: #000000; font-weight: bold;">/</span>corporate-git<span style="color: #000000; font-weight: bold;">/</span>test.git<span style="color: #000000; font-weight: bold;">/</span>info<span style="color: #000000; font-weight: bold;">/</span>refs</pre></div></div>



<p>And so on...</p>
</div>
</div>
</div>
<div class="section" id="usage">
<h3><a class="toc-backref" href="#id28">3&nbsp;&nbsp;&nbsp;Usage</a></h3>
<p>So everything is ready to use. How do you actually create and use
these new repositories?</p>
<div class="section" id="creating-new-bare-repositories">
<h4><a class="toc-backref" href="#id29">3.1&nbsp;&nbsp;&nbsp;Creating new bare repositories</a></h4>
<p>In order to create a new repository, say <tt class="docutils literal">toyproject.git</tt>, all you
have to do is ssh into your Dreamhost account and:</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">~<span style="color: #000000; font-weight: bold;">/</span>newgit.sh <span style="color: #660033;">-r</span> <span style="color: #800000;">${GIT_REPOS_ROOT}</span> <span style="color: #660033;">-d</span> <span style="color: #ff0000;">&quot;My first private repository&quot;</span> <span style="color: #660033;">-n</span> toyproject</pre></div></div>



<p>That's it: your created and empty repository in you repository
collection. You can <em>clone</em> it if you want.</p>
</div>
<div class="section" id="cloning-an-empty-repository">
<h4><a class="toc-backref" href="#id30">3.2&nbsp;&nbsp;&nbsp;Cloning an empty repository</a></h4>
<p>So, you got a new pristine and empty repository. Let's <em>clone</em> it, shall we?:</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">git</span> clone http:<span style="color: #000000; font-weight: bold;">//</span>username<span style="color: #000000; font-weight: bold;">@</span>www.example.tld<span style="color: #000000; font-weight: bold;">/</span>corporate-git<span style="color: #000000; font-weight: bold;">/</span>toyproject.git
Initialized empty Git repository <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">/</span>private<span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>teste<span style="color: #000000; font-weight: bold;">/</span>.git<span style="color: #000000; font-weight: bold;">/</span>
Password:
warning: You appear to have cloned an empty repository.</pre></div></div>



<div class="important">
<p class="first admonition-title">Important</p>
<p>Have you noticed that we have a <tt class="docutils literal">username@</tt> in the URL? This
tells git that it must athenticate to the server before trying to
access the git repository.</p>
<p class="last">In this example, we are acessing the
repository with the crentials of the user <tt class="docutils literal">username</tt>, the one we
setup in <a class="reference internal" href="#password-protect-your-repository">Password-protect your repository</a>. Modify it to match
the user you created in that step.</p>
</div>
<p>But what if you already have a local repository and all you want is
push it and its history to the server?</p>
</div>
<div class="section" id="pushing-to-a-new-empty-repository">
<h4><a class="toc-backref" href="#id31">3.3&nbsp;&nbsp;&nbsp;Pushing to a new empty repository</a></h4>
<p>What you usually do is creating a local repository, adding file to it and committing this repository history to the new, empty and pristine repository in your web server:</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">mkdir</span> toyproject
<span style="color: #7a0874; font-weight: bold;">cd</span> toyproject
<span style="color: #c20cb9; font-weight: bold;">git</span> init
<span style="color: #c20cb9; font-weight: bold;">touch</span> README
<span style="color: #c20cb9; font-weight: bold;">git</span> add README
<span style="color: #c20cb9; font-weight: bold;">git</span> commit <span style="color: #660033;">-m</span> <span style="color: #ff0000;">'first commit'</span>
<span style="color: #c20cb9; font-weight: bold;">git</span> remote add origin http:<span style="color: #000000; font-weight: bold;">//</span>username<span style="color: #000000; font-weight: bold;">@</span>www.example.tld<span style="color: #000000; font-weight: bold;">/</span>corporate-git<span style="color: #000000; font-weight: bold;">/</span>toyproject.git
<span style="color: #c20cb9; font-weight: bold;">git</span> push origin master</pre></div></div>



<p>If you have an existing Git Repo, that's the procedure:</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> existing_toyproject_git_repo
<span style="color: #c20cb9; font-weight: bold;">git</span> remote add origin http:<span style="color: #000000; font-weight: bold;">//</span>username<span style="color: #000000; font-weight: bold;">@</span>www.example.tld<span style="color: #000000; font-weight: bold;">/</span>corporate-git<span style="color: #000000; font-weight: bold;">/</span>toyproject.git
<span style="color: #c20cb9; font-weight: bold;">git</span> push origin master</pre></div></div>



<p>The above workflow follows what is presented in <a class="reference external" href="http://help.github.com/creating-a-repo/">http://help.github.com/creating-a-repo/</a>.</p>
</div>
</div>
<div class="section" id="final-remarks">
<h3><a class="toc-backref" href="#id32">4&nbsp;&nbsp;&nbsp;Final remarks</a></h3>
<p>If you need more than one collection of private repositories (say, one
for you and one to share privately with a group of coworkers), all you
need to do is:</p>
<blockquote>
<ol class="arabic simple">
<li>Create a directory for each of these collections.</li>
<li>Create copies of <tt class="docutils literal">newgit.sh</tt>, one for each collection, and setup
the value of GIT_REPOS_ROOT in each of them.</li>
<li>Adapt each .htaccess accordingly.</li>
<li>GitWeb: copy its files too.. Or just sym-link it from a pristine copy.</li>
</ol>
</blockquote>
</div>
<div class="section" id="todos">
<h3><a class="toc-backref" href="#id33">5&nbsp;&nbsp;&nbsp;TODOs</a></h3>
<ul class="simple">
<li>Focus on reusability.</li>
<li>Write the <a class="reference internal" href="#final-remarks">Final remarks</a> section properly.</li>
</ul>
<p><a class="reference external" href="http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewritecond">http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewritecond</a> --
serve directly w/ apache if...</p>
<p>Adding project .description directly in the scripts</p>
</div>
<div class="section" id="references">
<h3><a class="toc-backref" href="#id34">6&nbsp;&nbsp;&nbsp;References</a></h3>
<ul class="simple">
<li>arvinderkang.com - <a class="reference external" href="http://arvinderkang.com/2010/08/25/hosting-git-repositories-on-dreamhost/">Hosting Git repositories on Dreamhost</a></li>
<li>craigjolicoeur.com - <a class="reference external" href="http://craigjolicoeur.com/blog/hosting-git-repositories-on-dreamhost">Hosting Git Repositories on Dreamhost</a></li>
<li><a class="reference external" href="http://railstips.org/blog/archives/2008/11/23/gitn-your-shared-host-on/">Git'n Your Shared Host On</a></li>
<li><a class="reference external" href="http://faves.eapen.in/guide-to-hosting-git-repositories-on-dreamhos">http://faves.eapen.in/guide-to-hosting-git-repositories-on-dreamhos</a></li>
<li><a class="reference external" href="http://gist.github.com/73622">http://gist.github.com/73622</a></li>
<li><a class="reference external" href="http://wiki.dreamhost.com/Git#Smart_HTTP">http://wiki.dreamhost.com/Git#Smart_HTTP</a></li>
<li><a class="reference external" href="http://arvinderkang.com/2010/08/25/hosting-git-repositories-on-dreamhost/">http://arvinderkang.com/2010/08/25/hosting-git-repositories-on-dreamhost/</a></li>
<li><a class="reference external" href="http://www.kernel.org/pub/software/scm/git/docs/git-http-backend.html">git-http-backend</a> manpage</li>
<li><a class="reference external" href="http://progit.org/2010/03/04/smart-http.html">Pro Git - Smart HTTP Transport</a></li>
<li><a class="reference external" href="http://www.jedi.be/blog/2009/05/06/8-ways-to-share-your-git-repository/">http://www.jedi.be/blog/2009/05/06/8-ways-to-share-your-git-repository/</a></li>
<li><a class="reference external" href="http://help.github.com/creating-a-repo/">http://help.github.com/creating-a-repo/</a></li>
</ul>
<!-- .. target-notes:: -->
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.burocrata.org/blog/archives/2010/11/08/345/private-git-repositories-on-dreamhost/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Copiando tudo de uma partição WBFS pra outra</title>
		<link>http://www.burocrata.org/blog/archives/2010/10/25/353/copiando-tudo-de-uma-particao-wbfs-pra-outra/</link>
		<comments>http://www.burocrata.org/blog/archives/2010/10/25/353/copiando-tudo-de-uma-particao-wbfs-pra-outra/#comments</comments>
		<pubDate>Mon, 25 Oct 2010 23:00:47 +0000</pubDate>
		<dc:creator>MaCa</dc:creator>
				<category><![CDATA[DIY]]></category>
		<category><![CDATA[Nerdocracia]]></category>
		<category><![CDATA[homebrew]]></category>
		<category><![CDATA[wii]]></category>

		<guid isPermaLink="false">http://www.burocrata.org/blog/?p=353</guid>
		<description><![CDATA[Usando o WIT, Wiims ISO Tools, copiar todas as ISOs de uma partição WBFS para outra é um comando simples como: ./wwt  --update --progress --part  /dev/rdisk1s1 ADD /dev/rdisk2s1 Primeira partição (/dev/rdisk1s1) é a partição WBFS de destino, a segunda a partição (/dev/rdisk2s1) WBFS onde os jogos se encontram. Homebrews ou jogos já existentes não são sobrescritos, [...]]]></description>
			<content:encoded><![CDATA[<p>Usando o <a href="http://wit.wiimm.de/">WIT, Wiims ISO Tools</a>, copiar todas as ISOs de uma partição WBFS para outra é um comando simples como:</p>
<pre>./wwt  --update --progress --part  /dev/rdisk1s1 ADD /dev/rdisk2s1</pre>
<p>Primeira partição (<code>/dev/rdisk1s1</code>) é a partição WBFS de destino, a segunda a partição (<code>/dev/rdisk2s1</code>) WBFS onde os jogos se encontram.</p>
<p><em>Homebrews</em> ou jogos já existentes não são sobrescritos, ou seja: ele só copia o que você ainda não possui.</p>
<p>Para descobrir qual partição tem seus jogos, conecte apenas o seu HD e rode o <code>wwt</code> com aopção <code>LIST-M</code>:</p>
<pre>
./wwt LM
ScanDevForPartitions(sd)
- part found: /dev/sdt
ScanDevForPartitions(rdisk)
- part found: /dev/rdisk0
- part found: /dev/rdisk0s2
- part found: /dev/rdisk0s1
- part found: /dev/rdisk1
- part found: /dev/rdisk1s0
- part found: /dev/rdisk1s0s1
- part found: /dev/rdisk1s0s2
- part found: /dev/rdisk2
- part found: /dev/rdisk2s1
- part found: /dev/rdisk2s2
- part found: /dev/rdisk2s3
WI  WBFS file
-------------------
1  /dev/rdisk2s1
-------------------
ID6     MiB Reg.  WI  40 discs (105 GiB)
--------------------------------------------------------------------
&lt;lista de jogos homebrew aqui...&gt;
--------------------------------------------------------------------
Total: 40 discs, 107092 MiB ~ 105 GiB used, 36432 MiB ~ 36 GiB free.
</pre>
<p>Pronto.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.burocrata.org/blog/archives/2010/10/25/353/copiando-tudo-de-uma-particao-wbfs-pra-outra/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Dia do Blog</title>
		<link>http://www.burocrata.org/blog/archives/2010/08/31/340/dia-do-blog/</link>
		<comments>http://www.burocrata.org/blog/archives/2010/08/31/340/dia-do-blog/#comments</comments>
		<pubDate>Tue, 31 Aug 2010 15:38:49 +0000</pubDate>
		<dc:creator>MaCa</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.burocrata.org/blog/?p=340</guid>
		<description><![CDATA[Bom, disseram por aí que hoje é o dia do blog. Aproveitando a deixa, mando o link para uma matéria entitulada &#8220;Como ser índo&#8221; do EpicShit, o blog recomendado de hoje.]]></description>
			<content:encoded><![CDATA[<p>Bom, <a href="http://twitter.com/malvados/status/22617001181">disseram por aí </a>que hoje é o<a href="http://pt.wikipedia.org/wiki/Dia_do_Blog"> dia do blog</a>. Aproveitando a deixa, mando o link para uma matéria entitulada &#8220;<a href="http://www.epicshit.com.br/2010/08/27/como-ser-indio/">Como ser índo</a>&#8221; do <a href="http://www.epicshit.com.br">EpicShit</a>, o blog recomendado de hoje.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.burocrata.org/blog/archives/2010/08/31/340/dia-do-blog/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Curanderismo e fé na ciência</title>
		<link>http://www.burocrata.org/blog/archives/2010/08/26/326/curanderismo-e-fe-na-ciencia/</link>
		<comments>http://www.burocrata.org/blog/archives/2010/08/26/326/curanderismo-e-fe-na-ciencia/#comments</comments>
		<pubDate>Thu, 26 Aug 2010 20:10:03 +0000</pubDate>
		<dc:creator>MaCa</dc:creator>
				<category><![CDATA[Desculpas-Fu]]></category>
		<category><![CDATA[T.C.P.C.E.P.]]></category>
		<category><![CDATA[corrida]]></category>
		<category><![CDATA[running]]></category>
		<category><![CDATA[saúde]]></category>

		<guid isPermaLink="false">http://www.burocrata.org/blog/?p=326</guid>
		<description><![CDATA[(isso originalmente foi um e-mail enviado à minha família mas, na falta de assunto melhor para por aqui e, dado que tem mais gente sabendo disso que apenas minha família, creio que seja oportuno para um post.) Recapitulando Primeiro é bom dizer que já fazem uns 8 ou 9 meses que eu reclamo de dores [...]]]></description>
			<content:encoded><![CDATA[<p>(isso originalmente foi um e-mail enviado à minha família mas, na falta de assunto melhor para por aqui e, dado que tem mais gente sabendo disso que apenas minha família, creio que seja oportuno para um <em>post</em>.)</p>
<h3>Recapitulando</h3>
<p>Primeiro é bom dizer que já fazem uns 8 ou 9 meses que eu reclamo de dores na perna esquerda (região da bunda/coxa) e no pé.</p>
<p>É bom dizer que fiz 20 sessões de fisioterapia para ambos no início do ano apenas para ficar frustrado com a perda de tempo. Não deve-se ainda esquecer que eu corri um Volta da Pampulha no final do ano passado, que estava treinando para a maratona que corri em maio e que agora em julho corri uma meia maratona no Rio e outra meia agora em agosto. Ou seja: eu não estava exatamente pegando leve nesses meses, mas a dor não aumentou nem me impediu de fazer nada.</p>
<p>Durante esse tempo as dores no pé iam e voltavam, idem a da perna.  Ambas não me incomodam para correr de maneira quase nenhuma mas me incomodam no dia-a-dia: o pé às vezes dói ao andar e a perna quando fico sentado muito tempo, principalmente na cadeira do escritório aqui de casa. O pé às vezes dá aquela &#8220;pontada&#8221; de agulha. Na perna, por outro lado, a dor não é angustiante, mas sim um incômodo que persiste enquanto eu ficar sentado &#8212; que é o que eu faço na maior parte do dia.</p>
<p>O primeiro médico que ao qual fui, logo no início do ano, disse que eu estava com fasceíte plantar. O que é isso? Uma dor numa espécie de ligamento que existe no pé e que percorre toda a extensão dele. Para uma explicação mais correta e detalhada recomendo <a href="http://pt.wikipedia.org/wiki/Fascite_plantar">um artigo sobre o assunto na wikipedia em português</a> e <a href="http://en.wikipedia.org/wiki/Plantar_fasciitis">a sua versão na wikipedia em inglês</a>, que possui mais referências.</p>
<h3>Terapia por ondas de choque</h3>
<p>Fui para um ortopedista com especialidade em pé sexta passada apresentar o resultado da ressonância magnética que fiz sob pedido dele. Esse médico me foi indicado por outro que, por sua vez, me foi muito bem recomendado por várias pessoas do meu grupo de corrida. A fisioterapeuta que me atende também gosta muito do trabalho dele.</p>
<p>Ao olhar a minha ressonância ele disse que eu tinha fasceíte plantar, que é uma doença comum em corredores. Confesso que a essa altura já achava que não, que eu não tinha fasceíte mas sim outra coisa. Enfim, esse diagnóstico também foi feito olhando um raio-x do meu pé, que por sua vez servia para descartar a possibilidade de uma fratura por estresse.  Diagnóstico feito, ele enumerou os tratamentos recomendados e, dentre estes, me indicou fazer terapia por ondas de choque &#8212; e é aí onde os problemas começam.</p>
<p>Primeiro porque não é uma &#8220;<em>terapia</em>&#8221; no sentido que são várias sessões.  Está mais para um &#8220;procedimento&#8221;. Digo isso porque espera-se que seja apenas uma aplicação. E ela leva anestesia e requer que eu passe umas 24 horas após o procedimento em repouso absoluto,  &#8221;só saindo da cama para ir ao banheiro&#8221;. Perfeito, né? Segundo o médico, a chance de sucesso desse procedimento é de 70%. Eu teria ainda que ficar sem correr antes de fazer o tratamento e, após feito, por mais um mês, quando então eu marcaria uma consulta de retorno para ver se &#8220;deu certo&#8221;.  Caso não dê, segundo disse a atendente do hospital que faz esse tratamento, teria de pagar mais 20% para uma  &#8221;re-aplicação&#8221;.</p>
<p>Por outro lado, segundo meu plano de saúde, esse procedimento não está na lista de procedimentos &#8220;reconhecidos&#8221; ou &#8220;cadastrados&#8221; pelo mesmo.  Talvez eu possa fazê-lo e ser reembolsado. Talvez não.   O fato é eles ficaram de me dar uma posição sobre isso. Espero que eles possam cobrir os custos porque, a R$ 1000 (mil) a aplicação, não é exatamente algo que eu acho que dê para fazer sem ajuda do plano. Pelo menos não sem ter certeza de que essa é a solução e que esse é realmente o procedimento necessário.</p>
<h3>Alongamento</h3>
<p>Bom, eu senti confiança (item escasso ultimamente) no médico que me prescreveu esse tratamento mas, dado o custo dele e tudo que ele envolvia, resolvi acatar os conselhos de amigos de pegar uma segunda opinião. Num aniversário sábado passado conheci um amigo de uma amiga minha que é fisioterapeuta e que tinha um amigo médico ortopedista com especialidade em pés.  Conveniente, não? Bom, como ele também não poupou elogios ao amigo, fui lá. Pior do que está não fica, certo?</p>
<p>Nesse meio tempo a dor do pé sumiu mas, como também não estou correndo como corria antes, isso era de certa forma esperado.</p>
<p>Bom, chego lá e existe não um mas dois médicos na sala. O cara olha meu pé, vê que o meu pé não estava doendo, vê a ressonância e diz que sim, que é fasceíte mas que não, que não precisa fazer esse tratamento &#8212; e agora é que a coisa fica realmente interessante.</p>
<p>Não preciso fazer esse tratamento porquê ele não presta. Porque em 7 anos em que ele trabalha com ortopedia só viu um caso de precisar de operação. E não, não era tratamento por onda de choque ao que ele se referia. Além disso, como parte do tratamento por terapia por ondas de choque, eu teria de passar um mês sem correr. Ora, mas se você passar um mês sem correr você não vai melhorar de qualquer forma não? Sendo assim, como você pode afirmar que foi o tratamento de R$ 1000 que lhe resolveu o problema ou foi parar de correr? O outro médico, só completava aquilo que o primeiro dizia de vez em quando.</p>
<p>Ele ainda disse que os trabalhos científicos que sugerem o uso desse tratamento possuem uma qualidade 4 ou 5. Pelo que eu saquei, isso quer dizer que eles estão no fundo de uma escala de qualidade e que, no caso particular deles, quer dizer que eles foram feito sem ter um embasamento estatístico correto &#8212; não foi usado um grupo aleatório, não houve separação de grupos com quadros similares usando tratamentos distintos, grupo usando placebo <em>etc</em>. A entrada na Wikipedia em inglês para Plantar Fasciitis diz que os estudos (links para esses são providos lá) não são conclusivos sobre a eficácia dessa técnica.</p>
<p>O remédio prescrito? Alongar, 3x por dia a batata da perna. Sim. A perna. A idéia é que o encurtamento da musculatura da perna acaba sobrecarregando o resto da musculatura do pé e isso acaba causando um impacto na fáscia plantar. Ah! E usar uma palmilha para o calcanhar. E retornar em um mês para lhe dizer como as coisas estão. E sim, parar por uma semana. Como eu não estou em treinamento para nenhuma corrida de longa distância, esse é o melhor período para dar uma pausa sem prejuízos ao treino e para dar uma folga tanto para a perna como para o pé.</p>
<p>Assim como o outro havia dito quando lhe indaguei, fazer spining e nadar nesse período, em substituição à corrida, seria o ideal.</p>
<p>Finalmente, ele me deu um concelho: <strong>NUNCA</strong>, <strong>JAMAIS</strong>, faça infiltração.  Se quiseram fazer isso, <strong>FUJA</strong>! Dói horrores na hora, depois parece que fica uma maravilha mas a chance disso acarretar um problema <strong>MUITO</strong> mais sério (rompimento na fáscia, etc) é enorme.</p>
<h3>Terceira opinião</h3>
<p>Ainda existe mais um cara a quem eu queria pedir informações e de quem queria recolher opiniões. Ele é um fisioterapeuta amigo de um amigo próximo que, novamente, é muito bem cotado pela qualidade do seu trabalho. Como ele trabalha numa clínica que é especializada nisso (medicina esportiva) imaginei que ele poderia conhecer alguém bom para me recomendar.</p>
<h3>Ah! A angústia…</h3>
<p>Olha, não sei o que pensar mais.</p>
<p>Por mais que esse último tenha dado mais informações, ligado pontos que eu achava que tinham de ser ligados (a perna e o problema no pé apareceram mais ou menos juntos de qualquer forma), achei muito mágico &#8220;só alongar&#8221;. Mas faz sentido. De qualquer forma, terei de esperar o plano se pronunciar sobre se eles pagam ou não esse tratamento por ondas de choque. É o tempo de conseguir a terceira opinião.</p>
<p>Chato é a sensação de impotência diante disso. De não saber o que pensar, o que fazer. De ter de ficar pescando pedaços de informação de cada um para pode compor um quadro incompleto. De achar que você está mudando de um &#8220;pajé&#8221; para outro. De ficar pescando informações na internet e acabar somatizando coisa que você lê, de se auto-sugestionar. Foda é achar que medicina é pseudo-ciência, que o curanderismo e o &#8220;assim me parece melhor&#8221; são o que me resta. Tenho medo quando começar a desenvolver coisas realmente sérias. Terei de pedir resumés e ver o perfis no Portal da CAPES antes de ir a um médico?</p>
<p>Nesse meio tempo um colega de UFMG muito chapa me mandou o seguinte artigo do NYT que, curiosamente, apóia a linha apontada pelo último médico: <a href="http://www.nytimes.com/2008/09/14/sports/playmagazine/0914play-PHYSED.html?_r=1">Unhappy feet</a>. Um outro artigo só para engroçar o coro: <a href="http://www.dallasnews.com/sharedcontent/dws/fea/healthyliving/fitness/stories/DN-nh_stretch_0330gd.ART.State.Edition1.4c8639c.html">Stretching your body&#8217;s fascia can improve exercise results</a>.</p>
<p>Bom, hora do ateu aqui ter fé na ciência. É o que me resta. Só preciso escolher qual profeta escutar.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.burocrata.org/blog/archives/2010/08/26/326/curanderismo-e-fe-na-ciencia/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>O portão</title>
		<link>http://www.burocrata.org/blog/archives/2010/04/22/323/o-portao/</link>
		<comments>http://www.burocrata.org/blog/archives/2010/04/22/323/o-portao/#comments</comments>
		<pubDate>Thu, 22 Apr 2010 19:55:09 +0000</pubDate>
		<dc:creator>MaCa</dc:creator>
				<category><![CDATA[Desculpas-Fu]]></category>
		<category><![CDATA[Doutorado]]></category>
		<category><![CDATA[escrita]]></category>
		<category><![CDATA[português]]></category>
		<category><![CDATA[tese]]></category>

		<guid isPermaLink="false">http://www.burocrata.org/blog/?p=323</guid>
		<description><![CDATA[O que ocorre é o seguinte. Tenho de escrever uma proposta de tese, alguns artigos e uma tese. Não é nada do outro mundo, não é nenhuma tarefa hercúlea &#8212; ou pelo menos não deveria sê-lo. Infelizmente, toda a habilidade de escrita que eu tinha aparentemente foi deixada de lado em algum momento entre o [...]]]></description>
			<content:encoded><![CDATA[<p>O que ocorre é o seguinte. Tenho de escrever uma proposta de tese, alguns artigos e uma tese. Não é nada do outro mundo, não é nenhuma tarefa hercúlea &#8212; ou pelo menos não deveria sê-lo.</p>
<p>Infelizmente, toda a habilidade de escrita que eu tinha aparentemente foi deixada de lado em algum momento entre o vestibular e o mestrado. Qualquer habilidade de programação que eu tenha talhado nesse meio tempo não tem serventia quase nenhuma quando o problema em questão é tecer um mero texto relatando sobre o que se trata a minha tese, porque ela vale um título de doutorado e o que eu fiz de concreto nela. <em>Unit tests</em> não valem de nada. Comentários no código &#8220;tampoco&#8221;.  Diagramas de seqüência podem até servir para aumentar a contagem de páginas mas, concretamente, não resolvem o problema de escrita.</p>
<p>Na falta de outra opção, o jeito é escrever. E como escrever tem sido difícil, o jeito é praticar. Praticar com regularidade, mesmo sem vontade, mesmo sem querer. Isso funcionou bem comigo nas corridas (de treinos de 4 km saí para treinos de 30 km e provas de 42 km) então espero que sirva na escrita.</p>
<p>E é por isso que eu voltei. Espero que agora para ficar. Não esperem textos &#8220;querido diário&#8221;. Mesmo sabendo que eles ocorrerão, esse não é foco. Por hora, também não esperem <em lang="en">posts</em> multi-linguais &#8212; a escrita na língua de Camões já está sendo complicada o suficiente.</p>
<p>E só. Eu voltei.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.burocrata.org/blog/archives/2010/04/22/323/o-portao/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Exporting a git repository to subversion</title>
		<link>http://www.burocrata.org/blog/archives/2009/10/06/309/exporting-a-git-repository-to-subversion/</link>
		<comments>http://www.burocrata.org/blog/archives/2009/10/06/309/exporting-a-git-repository-to-subversion/#comments</comments>
		<pubDate>Tue, 06 Oct 2009 20:50:39 +0000</pubDate>
		<dc:creator>MaCa</dc:creator>
				<category><![CDATA[DIY]]></category>
		<category><![CDATA[Nerdocracia]]></category>

		<guid isPermaLink="false">http://www.burocrata.org/blog/?p=309</guid>
		<description><![CDATA[Yeah, you read that right. That is probably the inverse of what most people want. But, anyway, let&#8217;s say you have a project originally hosted on a git repository and you need to export it to a subversion repository for some reason. Now what? The nice folks of Google Code have put a really good [...]]]></description>
			<content:encoded><![CDATA[<p>Yeah, you read that right. That is probably the inverse of what most people want. But, anyway, let&#8217;s say you have a project originally hosted on a git repository and you need to export it to a subversion repository for some reason.  Now what?</p>
<p>The nice folks of <a href="http://code.google.com">Google Code</a> have put a really good <a href="http://code.google.com/p/support/wiki/ImportingFromGit">step-by-step guide explaining how to do it</a>. This guide was <a href="http://google-opensource.blogspot.com/2008/05/export-git-project-to-google-code.html">originally posted on Google Open Source Blog</a>. In case you need another view on the process, you can follow the <a href="http://n2.nabble.com/git-export-to-svn-td1376454.html">&#8220;git export to svn&#8221;</a> discussion on nabble &#8212; which just get good at the very end.</p>
<p>There is a little gotcha on the guide &#8212; not an error, but something they should have stressed. The Subversion repository you will use must be non-empty. Again: <strong>the Subversion repository must be non-empty</strong>.  Notice that by non-empty all they mean is that the subversion repository should have at least one revision <em>commited</em> to it, and not that it ought to have files in it. Got it? Good. Now move on.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.burocrata.org/blog/archives/2009/10/06/309/exporting-a-git-repository-to-subversion/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Reparo no Time Machine</title>
		<link>http://www.burocrata.org/blog/archives/2009/10/02/279/reparo-no-time-machine/</link>
		<comments>http://www.burocrata.org/blog/archives/2009/10/02/279/reparo-no-time-machine/#comments</comments>
		<pubDate>Fri, 02 Oct 2009 03:35:47 +0000</pubDate>
		<dc:creator>MaCa</dc:creator>
				<category><![CDATA[DIY]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[T.C.P.C.E.P.]]></category>

		<guid isPermaLink="false">http://www.burocrata.org/blog/?p=279</guid>
		<description><![CDATA[Então, como eu falei antes, enviei o meu Macbook para o reparo, onde trocaram a placa lógica dele. Depois disso o Time Machine parou de reconhecer o disco de backup antigo que eu usava. Na verdade, ele passa a ignorar todos os backups anteriores e resolve criar um backup novo, do zero. Desnecessário dizer que [...]]]></description>
			<content:encoded><![CDATA[<p>Então, como eu falei antes, <a href="http://www.burocrata.org/blog/archives/2009/09/28/270/reparo-no-mac/">enviei o meu Macbook para o reparo, onde trocaram a placa lógica dele. Depois disso o Time Machine parou de reconhecer o disco de backup antigo que eu usava</a>. Na verdade, ele passa a ignorar todos os backups anteriores e resolve criar um backup novo, do zero. Desnecessário dizer que isso tira metade da graça em usar o Time Machine (backups temporais), sem comentar os desperdício em espaço em disco &#8212; vou praticamente ter duas cópias dos mesmos dados do disco de backup.</p>
<blockquote><p>E aí, Bial, como fazer para resolver isso?</p></blockquote>
<p>Existem bons guias em inglês dizendo como resolver; coloquei links para eles ao final desse post. Mas, para aqueles que têm algum problema com o inglês, vamos ao passo-a-passo de como resolver isso na velha língua de Camões. Como alguns comandos requerem o uso da linha de comando, vou assumir certa familiaridade com a mesma.</p>
<h3>Entendendo o Problema</h3>
<p>Antes de mais nada, uma rápida explicação. O Time Machine usa um identificador que fica atrelado à sua placa de rede (o seu &#8220;<a href="http://pt.wikipedia.org/wiki/Endereço_MAC">endereço MAC</a>&#8220;) para reconhecer o backup de um micro. Isso permite inclusive que um mesmo disco de backup seja compartilhado por vários micros: cada um terá seu backup identificado unicamente pelo endereço MAC do seu respectivo micro.</p>
<p>Todavia, se a placa lógica de um micro muda, o endereço MAC dela também muda. Por isso, quando o Time Machine for procurar por backups anteriores do seu micro, ele procurará backups associados ao identificar atual do micro &#8212; ou seja, ao seu novo endereço MAC. E é por isso que ele não encontrará seus backups anteriores: todos os seus backups ainda estão atrelados ao antigo identificador do seu micro e não ao novo. Para corrigir esse problema temos que &#8220;informar&#8221; o Time Machine sobre essa mudança de identificador. Na prática, apenas atualizaremos o endereço MAC nos backups antigos com o novo endereço MAC. Assim, o Time Machine identificará seus backups anteriores como backups do micro atual e nada do seu histórico será perdido.</p>
<h3>Coletando algumas informações</h3>
<p>Antes de prosseguir, você terá de cololetar algumas informações</p>
<ul>
<li><strong><em>Mount-point</em> do Time Machine</strong><br />Provavelmente será dentro do <code>/Volumes</code>, alguma coisa como <code>'/Volumes/Time Machine'</code> ou, no meu caso, <code>'/Volumes/Backups do Time Machine/'</code>.</li>
<li><strong>Diretório onde o Time Machine guarda os backups antigos do seu micro</strong><br />Dentro do volume/mount-point do Time Machine haverá uma pasta chamada <code>Backups.backupdb</code> e, dentro dessa pasta, haverá uma (provavelmente) com o nome do seu micro. Essa é a pasta que contém os seus backups antigos. No meu caso, o path completo para ele era <code>/Volumes/Backups do Time Machine/Backups.backupdb/notebook</code></li>
<li><strong>O antigo endereço MAC do seu micro</strong><br />Sim! Você vai precisar dessa informação. Se você não tinha anotado o seu antigo endereço MAC em algum lugar o que lhe resta é extrair essa informação direto do Time Machine. O comando abaixo deve resolver esse problema. Adapte as nomes dos diretórios de acordo com as suas configurações<br />
<code><br />
$ cd /Volumes/Backups\ do\ Time\ Machine/Backups.backupdb/<br />
$ xattr -p com.apple.backupd.BackupMachineAddress notebook<br />
</code><br />
A saída desse comando deve ser algo como <code>00:1e:c2:1e:1e:ca</code>. Esse é o valor do seu antigo endereço MAC.
</li>
<li><strong>O novo endereço MAC do seu micro</strong><br />O comando abaixo deve dar conta de lhe fornecer essa informação<br />
<code><br />
$ LC_ALL=C ifconfig en0 | awk '/ether/{print $2}'<br />
</code><br />
O resultado deve ser um identificador como <code>00:22:41:22:16:f3</code>. Esse é o endereço MAC atual do seu micro.
</li>
</ul>
<h3>Passo-a-Passo</h3>
<p>De posse de todas as informações necessárias, vamos agora ao passo-a-passo para resolver esse problema.</p>
<ol>
<li>Se o disco de backup estiver conectado, desconecte-o.</li>
<li>Em seguida, desligue o Time Machine. Você não vai querer ele interagindo com você enquanto os ajustes são feitos. Vá lá no &#8220;Preferências do Sistema&#8221;, vá na área do Time Machine e desligue-o.</li>
<li>Reconecte seu disco de backup.</li>
<li>Desabilite temporariamente as ACLs no volume da Time Machine. Não precisa ficar com cara de Amélia se você não entendeu. Apenas digite os comandos abaixo:<br />
<code><br />
$ sudo fsaclctl -p '/Volumes/Backups do Time Machine/' -d<br />
</code>
</li>
<li>Dentro do raiz do volume do Time Machine existe um arquivo invisível cujo nome corresponde ao identificador MAC antigo do seu micro precedido por ponto e sem os &#8220;:&#8221;, ou seja &#8220;<code>.001ec21e1eca</code>&#8220;. Esse arquivo terá de ser renomeado para refletir o valor do novo MAC. Aplique o mesmo processo ao novo MAC e você terá o novo nome  para esse arquivo.<br />
<code><br />
$ cd /Volumes/Backups do Time Machine/<br />
$ mv .001ec21e1eca .0022412216f3<br />
</code>
</li>
<li>O diretório com seus backups antigos possui um <a href="http://en.wikipedia.org/wiki/Extended_file_attributes">atributo extendido</a> com o valor do MAC antigo. Atualize-o com o valor do MAC novo.<br />
<code><br />
$ cd /Volumes/Backups do Time Machine/<br />
$ sudo xattr -w com.apple.backupd.BackupMachineAddress 00:22:41:22:16:f3 Backups.backupdb/notebook<br />
</code></li>
<li>Reabilite as ACLs no volume da Time Machine.<br />
<code><br />
$ sudo fsaclctl -p '/Volumes/Backups do Time Machine/' -e<br />
</code>
</li>
<li>Desconecte/Ejete o seu disco de backup</li>
<li>Re-habilite o Time Machine</li>
<li>Reconecte o seu disco de backup</li>
</ol>
<p>E é isso. Após tudo isso o Time Machine deverá iniciar um outro processo de backup &#8212; e esse deve demorar um pouco mais já que provavelmente seu micro estava há um bom tempo sem fazer backup.</p>
<h3>Referências</h3>
<ul>
<li><a href="http://www.macosxhints.com/article.php?story=20080128003716101">macosxhints.com:  10.5: Repair Time Machine after logic board changes</a></li>
<li><a href="http://www.macosxhints.com/article.php?story=20081216145458979">macosxhints.com: 10.5: A script to fix Time Machine after hardware repairs </a></li>
<li><a href="http://www.tombridge.com/rta/2008/01/after-the-apple.html">Adventures in troubleshooting: After The Apple Repair: Fixing Time Machine</a></li>
<li><a href="http://www.tuaw.com/2009/07/20/mac-301-time-machine-backups-after-your-macs-brain-surgery/">Mac 301: Time Machine backups after your Mac&#8217;s brain surgery</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.burocrata.org/blog/archives/2009/10/02/279/reparo-no-time-machine/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Reparo no Macbook Pro</title>
		<link>http://www.burocrata.org/blog/archives/2009/09/28/270/reparo-no-mac/</link>
		<comments>http://www.burocrata.org/blog/archives/2009/09/28/270/reparo-no-mac/#comments</comments>
		<pubDate>Mon, 28 Sep 2009 15:23:23 +0000</pubDate>
		<dc:creator>MaCa</dc:creator>
				<category><![CDATA[DIY]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[Nerdocracia]]></category>
		<category><![CDATA[T.C.P.C.E.P.]]></category>

		<guid isPermaLink="false">http://www.burocrata.org/blog/?p=270</guid>
		<description><![CDATA[Meu Macbook Pro estava com um problema estranho: desligava espontaneamente quando passava um tempo apenas na bateria, mesmo essa tendo carga. Bastava um &#8220;while true; do echo 1 > /dev/null; done&#8221; rodando em dois terminais para, em questão de minutos, o mac apagar. Mas apagar mesmo, de não voltar até que fosse ligado no cabo [...]]]></description>
			<content:encoded><![CDATA[<p>Meu Macbook Pro estava com um problema estranho: <a href="http://www.macbookrandomshutdown.com/">desligava espontaneamente</a> quando passava um tempo apenas na bateria, mesmo essa tendo carga. Bastava um &#8220;<code>while true; do echo 1 > /dev/null; done</code>&#8221; rodando em dois terminais para, em questão de minutos, o mac apagar. Mas apagar <strong>mesmo</strong>, de não voltar até que fosse ligado no cabo de força. E repetindo: a bateria ainda tinha (muita) carga.</p>
<p>Depois de muito adiar levei ele na assistência para ver se resolvia o problema. Antes de mais nada, tenho que dizer três coisas:
<ol>
<li>Primeiro, Deus salve o momento em que fiz meu plano AppleCare &#8212; valeu cada centavo!</li>
<li>Pela primeira vez na vida não me senti enganado por uma assistência técnica. Gostei muito do serviço lá da <a href="http://www.tecmania.com.br/">TecMania</a>, aqui em Belo Horizonte mesmo. Recomendo mesmo. <img src='http://www.burocrata.org/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  </li>
<li>Finalmente, <a href="http://www.burocrata.org/blog/archives/2009/10/02/279/reparo-no-time-machine/">PQP!, Time Machine!</a></li>
</ol>
<p>O que ocorreu foi que depois de descartarem que o problema fosse a bateria, que parecia estar normal nos testes, resolveram trocar a placa lógica (<em lang="en">logic board</em>) do coitado. Trocaram e o problema persistiu. Pegaram uma bateria zerada que havia chegado a pouco por lá e tentaram reproduzir o problema. Como não conseguiram, deduziram que foi a bateria, e que a minha estava claramente defeituosa. Menos mal, fiquei com uma bateria nova e uma placa lógica nova sem pagar nada. Digo, tudo pago pelo AppleCare.</p>
<p>Tudo foi bem rápido. Mais rápido do que o esperava e quase tão rápido quanto eu gostaria. Todavia, depois de ter a placa lógica trocada, o <acronym title="macbook pro">MBP</acronym> se comportou um pouco estranho:</p>
<ul>
<li>O iTunes disse que não podia mais tocar as músicas da  minha coleção porque não tinha permissão.</li>
<li>O Time Machine não reconhecia os backups antigos que eu tinha.</li>
<li>O VMWare Fusion passou a perguntar se eu tinha movido ou copiado minhas máquinas virtuais.</li>
</ul>
<p>O que ocorreu foi que com a mudança da placa lógica, muitos programas acharam que eu tinha mudado de micro, o que não foi  de fato o que ocorreu. No caso do iTunes foi só autorizar esse <em>&#8220;novo&#8221;</em> computador. O VMWare funcionou sem problemas depois que eu disse que &#8220;copiei&#8221; as máquinas virtuais. <a href="http://www.burocrata.org/blog/archives/2009/10/02/279/reparo-no-time-machine/">Com o Time Machine não foi bem assim&#8230;</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.burocrata.org/blog/archives/2009/09/28/270/reparo-no-mac/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

