]> sipb.mit.edu Git - ikiwiki.git/blob - doc/rcs/git.mdwn
web commit by ManojSrivastava
[ikiwiki.git] / doc / rcs / git.mdwn
1 [[meta title="Git"]]
2
3 [Git][git] is a distributed revison control system originally developed for
4 the Linux kernel. Ikiwiki supports storing a wiki in git.
5
6 [git]: http://git.or.cz/
7
8 Ikiwiki can run as a `post-update` hook to update a wiki whenever commits
9 come in. When running as a [[cgi]] with Git, ikiwiki automatically
10 commits edited pages, and uses the Git history to generate the
11 [[RecentChanges]] page.
12
13 ## git repository setup
14
15 When using Git, you probably want to set up three repositories:
16
17 * One of these repositories should be a bare repository (meaning that it does not have a working tree checked out), which the other two repositories will push to/pull from.  It is a bare repository, since there are problems pushing to a repository that has a working directory. This is called _repository_ in [[ikiwiki-makerepo]]'s manual page. Nominally, this bare repository has a`post-commit` hook that would change directory to the second repository (the working directory for ikiwiki), do a _git pull_, and refresh ikiwiki to regenerate the wiki with any new content.
18 * The second repository has a working tree which is used as ikiwiki's srcdir for compiling the wiki. **Never** push to this repository. When running as a [[cgi]], the changes are committed to this repository, and pushed to the master repository above. This is called _srcdir_ in [[ikiwiki-makerepo]]'smanual page.
19 * The third (and fourth, fifth, sixth -- however many pleases you) repository is a clone of the bare master repository above -- and this has a working directory for you to work on. Use either the `git` transport (if available), or `ssh`. These repositories may be on remote machines, your laptop, whereever you find convenient to hack on your wiki. Any new content should be pushed to the bare master repository when you are ready to publish it, and then the post-commit hook of the bare repository will ensure that the ikiwiki's source directory is updated, and the ikiwiki refreshed with the new content.
20
21 [[ikiwiki-makerepo]] can automate setting this up. Using three or more of repositories isn't the most obvious set up, but it works the best for typical ikiwiki use.  [[tips/Laptop_wiki_with_git]] describes a different way to set up ikiwiki and git.
22
23 It is **paramount** that you **never** push to the non-bare repository
24 ([this FAQ entry explains why](http://git.or.cz/gitwiki/GitFaq#head-b96f48bc9c925074be9f95c0fce69bcece5f6e73)).
25 Instead, clone the bare repository as mentioned above, and push **only** to the bare repository.
26
27 The ikiwiki `post-commit` hook should be put in the bare repository.
28
29 ## git repository with multiple committers
30
31 It can be tricky to get the permissions right to allow multiple people to
32 commit to an ikiwiki git repository. As the [[security]] page mentions,
33 for a secure ikiwiki installation, only one person should be able to write
34 to ikiwiki's srcdir. When other committers make commits, their commits
35 should go to the bare repository, which has a `post-update` hook that uses
36 ikiwiki to pull the changes to the srcdir.
37
38 One setup that will work is to put all committers in a group (say,
39 "ikiwiki"), and use permissions to allow that group to commit to the bare git
40 repository. Make both the post-update hook and ikiwiki.cgi be setgid
41 to the group, as well as suid to the user who admins the wiki. The
42 `wrappergroup` [[setup_file_option|usage]] can be used to make the wrappers
43 be setgid to the right group. Then the srcdir, including its git
44 repository, should only be writable by the wiki's admin, and *not* by the
45 group. Take care that ikiwiki uses a umask that does not cause files in
46 the srcdir to become group writable. (umask 022 will work.)