mkdoc fixups (plus one bug that never triggered)
[gitolite-doc.git] / overview.mkd
blob3e62b597dacaac868f630a1a30fe7e6d69e62443
1 <!-- options: toc -->
3 % Gitolite Overview
5 include sidebar-toc
7 Gitolite allows you to setup git hosting on a central server, with
8 fine-grained access control and many more powerful features.
10 # what is gitolite? {#what}
12 Gitolite is an access control layer on top of git.  Here are the features that
13 most people see:
15   * Use a single unix user ("real" user) on the server.
16   * Provide access to many gitolite users:
17       * they are not "real" users,
18       * so they do not get shell access.
19   * Control access to many git repositories:
20       * read access controlled at the repo level,
21       * and write access controlled at the branch/tag/file/directory level,
22         including who can rewind, create, and delete branches/tags.
23   * Can be installed without root access, assuming git and perl are already
24     installed.
25   * Authentication is most commonly done using sshd, but you can also use
26     "smart http" mode if you prefer (this may require root access to setup).
28 <div class="bg-green">
30 **New (April 2014): There's a [book on gitolite][book] out**.  I've received
31 some emails over the years asking where to donate for gitolite to show your
32 appreciation, and I've always refused politely.  Well, if you insist... buy
33 the book :-)
35 </div>
37 # why might you need it?
39 ## access control
41 Git by itself does not do any access control -- it relies on the transport
42 medium to do authentication ("who are you?"), and on OS file permissions to do
43 authorisation ("what are you allowed to do?").
45 Git also comes with a program called "git-shell" which can act as a restricted
46 login shell if you don't want users getting a proper shell.  Using this and
47 judicious use of Unix groups, you can allow some people read-only access while
48 others get read-write access, etc.  This is probably sufficient if your needs
49 are simple and don't change too often.
51 However, gitolite does this much better, and offers many more features.
53 ### basic use case
55 Gitolite is useful in any server that is going to host multiple git
56 repositories, each with many developers, where "anyone can do anything to any
57 repo" is not a good idea.  Here're two examples to illustrate.
59 .#d
61 This first example has 3 repos and 3 developers with different levels of
62 access to each repo.  It's a very simple, readable, syntax, and makes it easy
63 to answer questions like "what repos can bob push to" (answer: only 'bar').
65 .#d
67 .#! conf/vim-color
68     repo foo
69         RW+     =   alice
70         RW      =   carol
72     repo bar
73         RW+     =   bob
74         R       =   alice
76     repo baz
77         RW+     =   carol
78         R       =   alice bob
79 .end
81 .#r
83 .#d
85 This second example allows different levels of access to different branches
86 and tags for different developers:
88 .#d
90 .#! conf/vim-color
91     repo foo
92         RW+                         =   alice
93         RW  master                  =   bob
94         RW+ dev/                    =   bob
95         RW  refs/heads/tags/v[0-9]  =   ashok
96 .end
98 .#t
100 ## other features
102 Gitolite has many more features, as you might guess from the documentation
103 links on the right.  Here's a quick sample:
105 *   Very powerful rule language (decide based on branch/tag name, files/dirs
106     touched, size of changed files, number of changed files, etc.).
107 *   Convenience features for writing the rules (repo groups, user groups, get
108     user group info from LDAP, include files, macros...)
109 *   Highly customisable and scriptable, especially custom commands for users.
110     Many built-in commands and options.
111 *   Powerful and flexible mirroring system.
112 *   Users can create their own repos and set access rights (if you allow
113     them).
115 ## alternatives to gitolite {#alt}
117 ### unix permissions and ACLs
119 If you're a masochist, you could probably do example 1 with Unix permissions
120 and facls.  But you can't do example 2 -- git is not designed to allow that!
122 Here are some other disadvantages of the Unix ACL method:
124   * Every user needs a userid and password on the server.
125   * Changing access rights involves complex `usermod -G ...` mumblings
126     (I.e., the "pain" mentioned above is not a one-time pain!)
127   * *Viewing* the current set of permissions requires running multiple
128     commands to list directories and their permissions/ownerships, users and
129     their group memberships, and then correlating all these manually.
130   * Auditing historical permissions or permission changes is impossible.
132 ### Gerrit Code Review {#gcr}
134 The best real alternative to gitolite is Gerrit Code Review.  If code review
135 is an essential part of your workflow, you should use Gerrit.
137 Here're some high level differences between gitolite and Gerrit (as of about
138 mid-2012 or so):
140 **Size**: 3000+ lines of perl versus of 56,000+ lines of Java
142 **Architecture**: Gitolite sits on top of "standard" git and openssh, which
143 are assumed to already be installed.  Gerrit includes its own git stack (jgit)
144 and sshd (Apache Mina).  In Java tradition, they all come bundled together.
146 (Corollary: As far as I know jgit does not support the same hooks that 'man
147 githooks' talks about).
149 Gitolite uses a plain text config file; gerrit uses a database.
151 **User view**: Gitolite is invisible to users except when access is denied.
152 Gerrit is much more visible to devs because of its role in enforcing code
153 review, approvals, and workflow.
155 On a related note, gitolite does not do anything special with signed or
156 annotated tags, nor does it check author/committer identity.  However, it is
157 trivial to add your own code to do either (or if someone contributes it, to
158 just "enable" what ships with gitolite in a disabled state).
160 ### gitorious, gitlab, and others
162 Anecdotally, gitorious is very hard to install.  Comparison with gitolite may
163 be useless because I believe it doesn't have branch/tag level access control.
164 However, I can't confirm or deny this because I can't find any documentation
165 on the website.  In addition, the main website hides the source code very
166 well, so you already have a challenge!  [The only link I could find was tucked
167 away at the bottom of the About page, in the License section].
169 Gitorious has several, much newer, competitors offering web-based management,
170 issue tracker, wiki, and so on; try googling for gitlab, gitblit, and
171 rhodecode.  Many of them now offer branch level access control as well, to
172 some extent or other.
174 However, they are unlikely to be as [customisable][non-core] as gitolite is,
175 if you care about that sort of thing.
177 # how does it work?
179 At a very high level, gitolite relies on **sshd** (or **httpd** if you're
180 using the smart http mode) to authenticate the user and supply the username.
181 Based on this, and the command given, it decides whether to allow or deny the
182 request.
184 .gv ov01.png
186     [] [c] gc   [ label = "git client" ]
187     [] [c] ssh
188     [] [g] sshd
189     [] [g] grp  [ label = "git-receive-pack" ]
190     .eq ssh sshd
191     gc .. ssh .. sshd
192     grp .. sshd [ dir = back ]
194 .end
196 .gv ov02.png
198     [] [c] gc  [ label = "git client" ]
199     [] [c] ssh
200     [] [g] sshd
201     [] [y] gs  [ label = "gitolite-shell"   ]
202     [] [g] grp [ label = "git-receive-pack" ]
203     [] [y] uh  [ label = "update hook"   ]
204     .eq ssh sshd
205     gc .. ssh .. sshd
206     uh .. grp .. gs .. sshd [ dir = back ]
207     [] [r] d1 [ label = "deny" ]
208     [] [r] d2 [ label = "deny" ]
209     .eq gs d1
210     .eq uh d2
211     gs -> d1 [ style = dashed label = "?" ]
212     uh -> d2 [ style = dashed label = "?" ]
214 .end
218 Consider a push command in ssh mode.  Normally (i.e., without gitolite) this
219 would invoke 'git-receive-pack' on the server, and the flow would be somewhat
220 like this (left side is client, right side is server):
224 ![](ov01.png)
228 ----
232 When you install gitolite and setup the user, gitolite sets up ssh to
233 **force** the gitolite-shell command to run first, instead of the command
234 requested:
236 The 'gitolite-shell' program uses the username supplied by ssh, and the repo
237 name in the command, to decide if the user has write access to the repo or
238 not.
240 If he does have *some* write access, git-receive-pack is called, but that's
241 not the end of the story.  The branch/tag/file(s) he is pushing also need to
242 be checked, and gitolite sets up the update hook on the repo to do that.
246 ![](ov02.png)
250 A more detailed explanation, with figures, is [here][how].
252 # who uses it?
254 [Note that many of the users who are listed in this page may still be using
255 v2.x, presumably because it's working fine for them and there's no compelling
256 reason to upgrade, and I still support v2 at least for critical issues].
258 >   <hr />
259 >   If you're using gitolite and find it very useful in some way, I would
260 >   love to describe your use of it or add a link to your own description
261 >   of it here.  Of course, you can anonymise it as much as you need to.
262 >   <hr />
264 The **Fedora Project** controls access to over 10,000 package management
265 repositories accessed by over 1,000 package maintainers [using
266 gitolite][fedora].  This is probably the largest *confirmed* gitolite
267 installation anywhere.  The whole "big-config" option back in v2 (in v3
268 this is the default!) was initially done for them (their config file was so
269 big that without the big-config changes gitolite would just run out of memory
270 and die!).
272 [fedora]: http://lists.fedoraproject.org/pipermail/devel-announce/2010-July/000647.html
274 The **KDE project** [uses][kde] gitolite (in combination with redmine for
275 issue tracking and reviewboard for code review).  Apart from the usual access
276 control, the KDE folks are heavy users of the "ad hoc repo creation" features
277 enabled by wildrepos and the accompanying commands.  Several of the changes to
278 the "admin defined commands" were also inspired by KDE's needs.  See [section
279 5][kdes5] and [section 6][kdes6] of the above linked page for details.
281 [kde]: http://community.kde.org/Sysadmin/GitKdeOrgManual
282 [kdes5]: http://community.kde.org/Sysadmin/GitKdeOrgManual#Server-side_commands
283 [kdes6]: http://community.kde.org/Sysadmin/GitKdeOrgManual#Personal_repositories
284 [kdera]: http://permalink.gmane.org/gmane.comp.kde.scm-interest/1437
286 **Prof. Hiren Patel** of the University of Waterloo is responsible for the
287 existence of the fairly popular "[wildrepos][wild]" feature.  The
288 documentation was pretty much written with his use case in mind, but of course
289 it turns out to be useful for a lot of people, as you can see from the
290 previous para on KDE's use of gitolite.
292 In fact, he surprised the heck out of me once by saying that if it hadn't been
293 for this feature, he might not have used git itself -- which is a pretty
294 serious compliment if you think about the magnitude of the git project and my
295 little one-man show!
297 He explains his use of it [here][hiren].
299 [hiren]: http://caesr.uwaterloo.ca/wildrepos-in-gitolite/
301 **Gentoo Linux** has [just moved][gentoo1] their git repositories from gitosis
302 to gitolite. There are about 200 repositories, some of them are the so called
303 [overlays][gentoo2], official and unofficial/user overlays, plus several
304 developer and project repositories, used by more than 1000 people. That number
305 will be increased in the near future, as they are going to migrate some of
306 their CVS/SVN repositories there, plus they are offering overlays hosting for
307 users as well.
309 [gentoo1]: http://archives.gentoo.org/gentoo-dev/msg_2812c9b9e768f64b46360ab17b9d0024.xml
310 [gentoo2]: http://www.gentoo.org/proj/en/overlays/
312 **kernel.org**, the official distribution point for the Linux kernel, is the
313 latest (as of 2011-10) high-visibility installation.  According to [this
314 email][ko-ann] to the lkml, kernel.org decided to use gitolite for access
315 controlling their git repos.  Their [FAQ entry][ko-why] describes at a high
316 level why they chose gitolite.
318 This move also prompted the first ever security audit of gitolite by an
319 outside party.  Gitolite did great; see [here][audit] for details.  [NOTE: v3
320 has not had such an audit yet; if you did one, please let me know what you
321 found.  If you want to do one and need clarifications on anything or general
322 background let me know].
324 In addition, kernel.org was responsible for a serious rethink of a few rough
325 edges in gitolite, and smoothing them out was fun (the "playing with gitolite"
326 stuff, making the test suite simpler, "deny" rules for the entire repo).
328 [ko-ann]: http://lkml.org/lkml/2011/9/23/357
329 [ko-why]: http://www.kernel.org/faq/#whygitolite
330 [audit]: http://groups.google.com/group/gitolite/browse_thread/thread/8dc5242052b16d0f
332 The **Mageia Project** is [using][mageia-gitweb] gitolite 3 to manage its
333 git repositories and access control. The repositories are [defined][mageia-def]
334 in yaml files. A tool called [mgagit][mgagit] has been created and is
335 repsonsible for the generation of the gitolite configuration from the
336 yaml repos definitions, and the extraction of users' ssh keys from an
337 ldap directory into the gitolite configuration.
339 Gitolite and mgagit are installed using rpm packages and
340 [a puppet module][mageia-puppet].
342 [mageia-gitweb]: http://gitweb.mageia.org/
343 [mageia-def]: http://gitweb.mageia.org/infrastructure/repositories/software/
344 [mgagit]: http://gitweb.mageia.org/software/infrastructure/mgagit/
345 [mageia-puppet]: http://svnweb.mageia.org/adm/puppet/deployment/mgagit/
347 ----
349 A general note: if you see the list of high-profile users above, you will see
350 that gitolite benefits as much as they do; possibly more.
352 # license
354 Please see the [license][] section for details on the licenses for gitolite
355 code and documentation.
357 >   <hr />
358 >   <center>**NOTE**: GIT is a trademark of Software Freedom Conservancy and my use of
359 >   "Gitolite" is under license.</center>
360 >   <hr />
362 [basic]: basic.html
363 [advanced]: advanced.html
364 [book]: http://www.packtpub.com/gitolite-essentials/book