Sophie

Sophie

distrib > Fedora > 14 > x86_64 > media > updates > by-pkgid > ba9fe7781d529b2e7b31d8489f5e0b8e > files > 13

gitolite-1.5.3-2.fc14.noarch.rpm

<h1>administering and running gitolite</h1>

<p><em>Note</em>: some of the paths in this document use variable names.  Just refer to
<code>~/.gitolite.rc</code> for the correct values for <em>your</em> installation.</p>

<p>In this document:</p>

<ul>
<li><a href="#please_read_this_first">please read this first</a></li>
<li><a href="#adding_users_and_repos">adding users and repos</a></li>
<li><a href="#other_features">other features</a>
<ul>
<li><a href="#moving_pre_existing_repos_into_gitolite">moving pre-existing repos into gitolite</a></li>
<li><a href="#specifying_gitweb_and_daemon_access">specifying gitweb and daemon access</a></li>
<li><a href="#custom_hooks">custom hooks</a></li>
<li><a href="#hook_chaining">hook chaining</a></li>
<li><a href="#environment_variables_available_to_hooks">environment variables available to hooks</a></li>
<li><a href="#custom_git_config">custom git config</a></li>
</ul></li>
</ul>

<hr />

<p><a name="please_read_this_first"></a></p>

<h3>please read this first</h3>

<ul>
<li><p><strong><em>do NOT add new repos manually</em></strong>, unless you know how to add the
required hook as well.  Without the hook, branch-level access control will
not work for that repo, which sorta defeats the idea of using gitolite :-)</p></li>
<li><p>most normal (day-to-day) gitolite admin work is done by cloning the
gitolite-admin repo from the server to your workstation, making changes to
the clone, and pushing those changes back.  The installation steps in
<a href="http://github.com/sitaramc/gitolite/blob/pu/doc/0-INSTALL.mkd">doc/0-INSTALL.mkd</a> include the steps to do this clone if needed.</p></li>
</ul>

<p>Once you've cloned it, you're ready to add users and repos.</p>

<p><a name="adding_users_and_repos"></a></p>

<h3>adding users and repos</h3>

<ul>
<li><p>ask each user who will get access to send you a public key.  See other
sources (for example <a href="http://sitaramc.github.com/0-installing/2-access-gitolite.html#generating_a_public_key">here</a>) for how to do this</p></li>
<li><p>rename each public key according to the user's name, with a <code>.pub</code>
extension, like <code>sitaram.pub</code> or <code>john-smith.pub</code>.  You can also use
periods and underscores</p></li>
<li><p>copy all these <code>*.pub</code> files to <code>keydir</code> in your gitolite-admin repo
clone.  You can also organise them into various subdirectories of <code>keydir</code>
if you wish, since the entire tree is searched.</p></li>
<li><p>edit the config file (<code>conf/gitolite.conf</code> in your admin repo clone).  See
<code>conf/example.conf</code> in the gitolite source for details on what goes in
that file, syntax, etc.  Just add new repos as needed, and add new users
and give them permissions as required.  The users names should be exactly
the same as their keyfile names, but without the <code>.pub</code> extension</p></li>
<li><p>when done, commit your changes and push.  Any new repos you specified will
automatically be created (empty, but clonable) and users' access will be
updated as needed.</p></li>
</ul>

<p><a name="other_features"></a></p>

<h3>other features</h3>

<p><a name="moving_pre_existing_repos_into_gitolite"></a></p>

<h4>moving pre-existing repos into gitolite</h4>

<p>One simple way to add a pre-existing repo to gitolite is to let gitolite
create it as a brand new repo as in the previous section, and then, from an
existing clone, "push --all" to the new one.</p>

<p>However, if you have many existing repos to add, this can be time-consuming
and error-prone.  Here's how to take a bunch of existing repos and add them to
gitolite:</p>

<ul>
<li><p>make sure they're <em>bare</em> repos ;-)</p></li>
<li><p>log on to the server and copy the repos to <code>$REPO_BASE</code> (which defaults to
<code>~/repositories</code>), making sure that the directory names end in ".git".</p></li>
<li><p>back on your workstation, add each repo (without the <code>.git</code> suffix) to
<code>conf/gitolite.conf</code> in your gitolite-admin repo clone.  Then add, commit,
push.</p></li>
</ul>

<p><a name="specifying_gitweb_and_daemon_access"></a></p>

<h4>specifying gitweb and daemon access</h4>

<p>This is a feature that I personally do not use (corporate environments don't
like unauthenticated access of any kind to any repo!), but someone wanted it,
so here goes.</p>

<p>To make a repo or repo group accessible via "git daemon", just give read
permission to the special user "daemon".  See the <a href="http://github.com/sitaramc/gitolite/blob/pu/doc/3-faq-tips-etc.mkd#gwd">faq, tips, etc</a>
document for easy ways to specify access for multiple repositories.</p>

<p>There's a special user called "gitweb" also, which works the same way.
However, setting a description for the project also enables gitweb permissions
so you may as well use that method and kill two birds with one stone, like so:</p>

<pre><code>gitolite = "fast, secure, access control for git in a corporate environment"
</code></pre>

<p>You can also specify an owner for gitweb to show, if you like:</p>

<pre><code>gitolite "Sitaram Chamarty" = "fast, secure, access control for git in a corporate environment"
</code></pre>

<p>Note that gitolite does <strong>not</strong> install or configure gitweb/daemon -- that is
a one-time setup you must do separately.  All this does is:</p>

<ul>
<li>for daemon, create the file <code>git-daemon-export-ok</code> in the repository</li>
<li>for gitweb, add the repo (plus owner name, if given) to the list of
projects to be served by gitweb (see the config file variable
<code>$PROJECTS_LIST</code>, which should have the same value you specified for
<code>$projects_list</code> when setting up gitweb)</li>
<li>put the description, if given, in <code>$repo/description</code></li>
</ul>

<p>The "compile" script will keep these files consistent with the config settings
-- this includes removing such settings/files if you remove "read" permissions
for the special usernames or remove the description line.</p>

<p><a name="custom_hooks"></a></p>

<h4>custom hooks</h4>

<p>You can supply your own, custom, hook scripts if you wish.  Just put a
<strong>tested</strong> hook script in <code>hooks/common</code> of your gitolite clone (as
distributed, there are only two files there).  For each file in that
directory, a symlink pointing to it will be placed in the <code>hooks/</code>
subdirectory of every <em>new</em> repo created.</p>

<p>If you added any new hooks and wish to propagate them to <em>existing</em> repos as
well, just run gl-easy-install (or gl-setup, if you installed directly on the
server) once.</p>

<p><strong>VERY IMPORTANT SECURITY NOTE:  the <code>update</code> hook in <code>hooks/common</code> is what
implements all the branch-level permissions in gitolite.  If you fiddle with
the hooks directory, please make sure you do not mess with this file
accidentally, or all your fancy per-branch permissions will stop working.</strong></p>

<p><a name="hook_chaining"></a></p>

<h4>hook chaining</h4>

<p>Gitolite basically takes over the update hook for all repos, but some setups
really need the update hook functionality for their own purposes too.  In
order to allow this, Gitolite now exec's a hook called <code>update.secondary</code> when
it's own "update" hook is done and everything is ready to go.</p>

<p>You can create this <code>update.secondary</code> hook manually on selected repos on the
server, or use the mechanism in the previous section to make gitolite put it
on <em>all</em> your repos.</p>

<p>Similarly, gitolite also takes over the post-update hook for the special
"gitolite-admin" repo.  This hook will also chain to a <code>post-update.secondary</code>
if such a hook exists.  People wishing to do exotic things on the server side
when the admin repo is pushed should see doc/shell-games.notes for how to
exploit this :-)</p>

<p>Finally, these names (<code>update.secondary</code> and <code>post-update.secondary</code>) are
merely the defaults.  You can change them to anything you want; look in
conf/example.gitolite.rc for details.</p>

<p><a name="environment_variables_available_to_hooks"></a></p>

<h4>environment variables available to hooks</h4>

<p>The following environment variables are set, and may be useful for any custom
processing you wish to do in your hook code:</p>

<ul>
<li><code>GL_USER</code> -- the user doing the push</li>
<li><code>GL_REPO</code> -- the reponame</li>
<li><code>GL_REPO_BASE_ABS</code> -- the absolute base path where all the repos are kept</li>
</ul>

<p>The following variables are also set, but are generally less useful:</p>

<ul>
<li><code>GL_BINDIR</code> -- where all the binaries live</li>
<li><code>GL_ADMINDIR</code> -- common directory for many gitolite things</li>
</ul>

<p><a name="custom_git_config"></a></p>

<h4>custom git config</h4>

<p>The custom hooks feature is a blunt instrument -- all repos get the hook you
specified and will run it.  In order to make it a little more fine-grained,
you could set your hooks to only work if a certain "gitconfig" variable was
set.  Which means we now need a way to specify "git config" settings on a per
repository basis.</p>

<p>Thanks to Teemu (teemu dot matilainen at iki dot fi), gitolite now does this
very easily.  For security reasons, this can only be done from the master
config file (i.e., if you're using delegation, the delegated admins cannot
specify git config settings).</p>

<p>Please see <code>conf/example.conf</code> for syntax.  Note that this only supports the
basic forms of the "git config" command:</p>

<pre><code>git config              section.key value   # value may be an empty string
git config --unset-all  section.key
</code></pre>

<p>It does not (currently) support other options like <code>--add</code>, the <code>value_regex</code>,
etc.</p>