misc
[gitolite-doc.git] / install.mkd
blob451b8429edb9affc35e424e530e4fa0dc27e3e67
1 <!-- options: toc -->
3 % install and setup
5 include sidebar-toc
7 @@box-r(**NOTE**: this page is about an ssh mode installation.  There's a
8 different page for [http mode][http] installation if you need that.)@@
10 This page talks about installing the software and setting it up.  The install
11 step gets the code to where you want it.  The setup step creates the files and
12 directories gitolite needs, including the special gitolite-admin repo, and
13 makes you an administrator so you can manage it remotely.
15 @@red(**NOTE** on package manager installs)@@: make sure you get gitolite
16 **v3.x**.  The correct package you want may be called "gitolite3", even though
17 "gitolite" also exists.  If you want to know what the latest gitolite version
18 is, the gitolite [CHANGELOG][cl] will tell you.
20 [cl]: https://github.com/sitaramc/gitolite/blob/master/CHANGELOG
22 @@red(**NOTE** on upgrades from v1 or v2)@@: upgrading from v1 or v2 is
23 reasonably easy, but, sadly, cannot be automated.  Instructions are
24 [here][migr].
26 # quick install+setup for experts {#qi}
28 If your Unix-fu and ssh-fu are good, just copy your ssh public key (i.e., the
29 `~/.ssh/id_rsa.pub` file) from your workstation to the hosting user, then do
30 something like this:
32     su - git
33     mkdir -p ~/bin
35     git clone git://github.com/sitaramc/gitolite
36     gitolite/install -ln ~/bin          # please use absolute path here
37     gitolite setup -pk yourname.pub
39 Please be sure to read any messages produced by these steps, especially the
40 last one, to make sure things went OK.
42 Notes:
44 1.  If your hosting user is not 'git', substitute accordingly.
45 2.  Make sure `~/bin` is in `$PATH`.  If it is not, add something to your
46     shell startup files to make it so.  If some other writable directory is in
47     the path, you can use that if you like.
48 3.  Substitute your name for "yourname" :-)
50 # the scenic route
52 Please DO read the [concepts and terminology][concepts] page before going
53 further.
55 ## (a graphical overview)
57 Here's a graphical overview of what files/directories are affected by each
58 step in the install+setup process.  Alice is installing gitolite, with herself
59 as the administrator.
61 .aa in-1.png
63 /-----------------\    /----------------------\
64 |  user "alice"   |    |     user "git"       |
65 |(on workstation) |    |     (on server)      |
66 |cPNK             |    |cGRE                  |
67 \-----------------/    \----------------------/
68 /-----------------\    /----------------------\
69 |~/.ssh/id_rsa.pub|--->|      alice.pub       |-----\
70 \----------+------/(1) \----------------------/     |
71                        /----------------------\     |
72            /---------->|     ~/gitolite       |-----+
73            | (2) /-----|                      |     |
74            |     |     \----------------------/     |
75            |     |     /----------------------\     |
76            |     |     |        ~/bin         |-----+
77            |     \---->|                      |     |
78            |       (3) \----------------------/     |
79 /----------+----\      /----------------------\     |
80 |    (github)   |      |    ~/.gitolite.rc    |     |
81 |cBLU           |      |~/.ssh/authorized_keys|<----/
82 \---------------/      |     ~/.gitolite      | (4)
83                        |    ~/repositories    |
84                        \----------------------/
86 .end
88 ![](in-1.png)
90 The files names you see there are **only for information**.  You do **not**
91 have to do anything to them yourself; in fact you should not!  You only need
92 the command for each step shown:
94 1.  Copy the admin's pubkey to the server as "alice.pub".
95 2.  Run `git clone git://github.com/sitaramc/gitolite` or equivalent.
96 3.  Run `gitolite/install -ln`.
97 4.  Run `gitolite setup -pk alice.pub`.
99 Note also that you only need ONE real user on the server.  In our example it
100 is git.  In particular, you do NOT create Unix userids for your gitolite
101 users.
103 ## prepare for the install
105 The simplest, most foolproof, way of ensuring that your gitolite install +
106 setup will succeed is to use a brand new userid as the hosting user.  If that
107 is not possible, make sure the following do NOT exist in that user's home
108 directory: `~/.gitolite.rc`, `~/.gitolite`, `~/repositories`, and
109 `~/.ssh/authorized_keys`.
111 @@red(Before you go trashing that authorized keys file, please make sure you
112 know the password to the 'git' user, or know the root password on the
113 machine!)@@
115 @@gray(The authorized keys file *can* exist, actually, as long as none of the
116 keys you intend to use with gitolite are present in it.  But again, if you're
117 not an ssh guru, you should probably play safe.)@@
119 ## get the software
121 Get the software using git-clone:
123     git clone git://github.com/sitaramc/gitolite
125 You can use this as is, or you can check out the latest tag to make sure
126 you're running a tagged version instead of just the current 'master'.
128 ## install
130 Gitolite has one server side command: `gitolite`.  You don't need to place it
131 anywhere special; in the worst case you can run it with the full path.
133 "Installation" consists deciding where to put it:
135 1.  Keep the sources anywhere and use the full path to run the `gitolite`
136     command.
137 2.  Keep the sources anywhere and symlink *just* the `gitolite` program to
138     some directory on your `$PATH`.
139 3.  Copy the sources somewhere and use that path to run the `gitolite`
140     command.
142 Option 2 is the best for general use, but here's the scoop on all of them:
144     # option 1
145     gitolite/install
147     # option 2
148     gitolite/install -ln
149     # defaults to $HOME/bin (which is assumed to exist)
150     #   ** or **
151     # or use a specific directory (please supply FULL path):
152     gitolite/install -ln /usr/local/bin
154     # option 3
155     # (again, please supply a FULL path)
156     gitolite/install -to /usr/local/gitolite/bin
158 Creating a symlink doesn't need a separate program but 'install' also runs
159 `git describe` to create a VERSION file, which can be very important if you
160 want support :-)
162 ## setup {#setup}
164 For the first-time setup, you need to have a public key file (usually from
165 the admin's workstation) ready.  If the main gitolite admin's username is
166 "alice", this file should be named "alice.pub" and copied to the server.
168 Once that is done, run:
170     gitolite setup -pk alice.pub
172 If that completes without any warnings, you are done.  If it had a warning,
173 you probably supplied a key which already has shell access to the server.
174 That won't work; you'll have to generate and use a different key pair for
175 gitolite access and use [host aliases][ssh-ha] to distinguish between the two.
176 While you're there, read both the [ssh][] pages.  Twice.
178 ----
180 The 'setup' command has other uses, so you will be running it at other times
181 after the install as well:
183   * To setup the update hook when you move [existing][] repos to gitolite.
184     This also applies if someone has been fiddling with the hooks on some
185     repos and you want to put them all right quickly.
187   * To replace a [lost admin key][lost-key].
189   * To setup gitolite for http mode (run 'gitolite setup -h' for more info).
191 When in doubt, run 'gitolite setup' anyway; it doesn't do any harm, though it
192 may take a minute or so if you have more than a few thousand repos!
194 # upgrading {#upgrading}
196   * Update your clone of the gitolite source.
197   * Repeat the install command you used earlier (make sure you use the same
198     arguments as before).
199   * Run `gitolite setup`.
201 # appendix 1: moving servers {#moving}
203 <!-- XXX TODO: maybe a nice picture? -->
205 @@box-r(Note: This section has one or more [forward references][fr].)@@
207 Nothing in any of the gitolite install/setup/etc will ever touch the *data* in
208 any repository except the gitolite-admin repo.  The only thing it will
209 normally touch is the `update` hook.  So one fool-proof way of "moving"
210 servers is this (XXX TODO XXX -- test this and remove the next phrase)
211 untested but should work; feedback appreciated):
213 1.  Clone the latest gitolite-admin repo from the old server to your
214     workstation.  Make sure you have an admin key that has RW+ rights to the
215     gitolite-admin repo; you will need this later.
217 2.  Install gitolite on the new server, using the same key for the admin as
218     for the old server.
220 3.  Copy the [rc][] file from the old server, overwriting this one.
222 4.  [Disable][writable] the old server so people won't push to it.
224 5.  Copy all the repos over from the old server.  Make sure the files end up
225     with the right ownership and permissions; if not, chown/chmod them.
227     The gitolite-admin repo already exists on the new server (it's just a bare
228     bones conf file).  Do NOT overwrite it.  (Not because it contains anything
229     useful, but because the next step will then fail!)
231 6.  Go to the clone you made in step 1, add a new remote (or change an
232     existing one) to point to the new server, then `git push -f` to it.
234 7.  Run `gitolite setup`.