various musings and babblings.

Hosting Your Own Git Repositories

Github is all the rage, but what if you don’t
want to store your code up in the sky? No, you want to host it
yourself. Or, more likely, you have to host it yourself, because
you work for some giant corporation who doesn’t believe in letting
their coders store their stuff in the unclean world.

So. What are your options?

Let’s back up a little. Why do you need to host git repositories at
all? What sorts of things should a hosting solution give you? First of
all, if you want to actually work with other people, and those other
people use, um, different computers, it is quite convenient to have a
central repository around to use as a conduit. Also, if you want to be
able to push changes anywhere, a central hosted git repository is a
not-very-confusing place to do so.

Generally hosting solutions range from just providing push and
clone access to a bare git repository somewhere, to bundling repository
browsers, bug trackers, wikis, graphs, ugh. The top end of the hosting
solutions integrates everything you need to run a successful software
project, the bottom end solutions do the bare minimum, letting other
apps handle the metaphorical heavy lifting. Unless you are the only one
going to use the hosted repositories, your hosting solution likely has
to deal with account management (i.e., letting other folks get accounts,
upload keys, etc.), and likely it will have to make trivial the task of
adding new repositories to the service. Some other things that it is
useful to know:

ssh is the gold standard for pushing changes. It can be done other
ways, but why waste your time with anything else?

The git protocol and http (or https) are pretty common for pull
protocols, although, you can use ssh too, of course. The nice thing
about using http is that is almost always works (unless you don’t
add the right post-commit hook). The git protocol is nice when it
isn’t blocked by an annoying firewall.

And back to the main business at hand: your hosting options. This list
is non-exhaustive, but it should get you headed in the right direction.

The high end:

github:fi. This is the commercially available version of
github that you can install yourself. It costs money, so it makes
it hard to install as part of a stealth project. Count on paying at
least $8k-ish. However, it does everything that github.com does, and
looks to be quite easy to install.

gitorious. (This project always makes me think of
Duran Duran.) As an
open source project, gitorious can be downloaded and installed on
your own system. I haven’t tried this yet, but it looks like it has
a fair number of dependencies, and no one has wrapped this thing up
in a nice bow for you, so installation may be non-trivial.

girocco. This
is basically gitweb on steroids. That is, it looks mostly like
gitweb, but also provides mechanisms to allow users to set up
repositories, handles “forks” of projects, and can “mirror” an
external git repository (that is, use a pull model rather than a
push model). It is a bit non-trivial to set up, but has fewer
dependcies than gitorious. You will likely have the easiest time of
it if you are installing onto Debian “Lenny” (so I gather from the
documentation). If you aren’t prepare to edit some of the scripts.

The low end:

gitolite/gitosis. Both of these packages do
roughly the same thing: manage user access. Project browsing,
repository creation, etc. are not included. The basic technique with
either tool is to create a single account (probably called ‘git’) on
your host, then uses the package to add other user’s ssh keys to
that account while still maintaining the idea that different users
are committing to the repositories. Of the two packages, gitolite is
still active and has more features, while gitosis hasn’t been
updated in 3 years. gitolite is implemented in Perl, gitosis in
Python.

Or, just give everyone an account on a machine and tell them the path
to the bare git repositories. Or you could use a combination of
straight ssh and gitosis/gitolite. With the “low end” solutions, you’d
typically want to set up repository browsing (at least). Fortunately,
git comes with a reasonable one, gitweb. However, there are others:
cgit,
Trac, and
FishEye, to name a few.