13

I have a working gitolite server. However, I want to move it to an identical configuration, but on a bigger machine. Even though I have gitolite working, I am not sure about the strings under it. Mainly its relationship with ssh.

I would like to just install the packages gitolite, git-core. And move the repository directories for the git user. None of the keys need to change. Is this correct ? what are the configuration ties gitolite has to the current server. I am working with Ubuntu

I was specially confused by gl-setup, which did the job, but leaves me in the dark about the process.

Thanks

jeremyvillalobos
  • 1,795
  • 2
  • 19
  • 39

2 Answers2

16

The instructions have changed for Gitolite V3

(Copied from http://gitolite.com/gitolite/rare.html):

  1. Install gitolite on the new server, using the same key for the admin as for the old server.

  2. Copy the .gitolite.rc file from the old server, overwriting this one.

  3. Disable the old server so people won't push to it. There are several ways to do this, but the simplest is to insert exit 1; at the top of ~/.gitolite.rc on the old server:

  4. Copy all the repos over from the old server, including gitolite-admin. Make sure the files end up with the right ownership and permissions; if not, chown/chmod them.

  5. Run gitolite setup.

  6. On a clone of the old gitolite-admin, add a new remote (or change an existing one) to point to the new server. Then git push -f to this remote.

mtpettyp
  • 5,533
  • 1
  • 33
  • 33
9

What you will need is also to move your ssh config:

~/.ssh/authorized_keys

That is the file used by SSH and configured by Gitolite in order to:

  • list all the authorized public key
  • associated it with a forced-command script
  • pass the right user name to the gitolite script

See "How Gitolite uses ssh"


The OP confirms that was the issue and points out to the Gitolite documentation:
"moving the whole thing from one server to another":
(note: this is for 'g2'; ie Gitolite V2, but the idea is the same for Gitolite V3 or 'g3')

The idea behind this process is to create a new Gitolite instance, and then push your existing Gitolite repo, which will redeclare automatically all your current existing keys in your new server ~/.ssh authorized_keys for you.

  • install gitolite. Don't worry about the pubkey used in the gl-setup step -- for example this will do fine:

    ssh-keygen -q -N '' -f dummy gl-setup -q dummy.pub

  • edit the rc file to have similar settings to the old one.

  • Do not copy the entire file outright -- some of the variables (notably GL_PACKAGE_CONF and GL_PACKAGE_HOOKS) are installation dependent and should not be touched!
    Do a diff or a vimdiff and copy across only what you know you changed on the old server.

  • disable the old server so your users will not push any changes to it.
    There are several ways to do this, but the simplest is to insert this line at the top of ~/.gitolite.rc on the old server:

    exit 1;

  • copy the contents of $REPO_BASE in the old server to $REPO_BASE on the new server.
    By default, as you know, these are both $HOME/repositories.

  • chown -R the files to the correct user if you copied using root.

  • fix up the hooks

    gl-setup

  • trigger a push to the admin repo

    git clone repositories/gitolite-admin.git /tmp/gitolite-admin cd /tmp/gitolite-admin git commit --allow-empty -m 'trigger compile on new server' gl-admin-push -f

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • 1
    Thanks for the replay. The link that helps the most is – jeremyvillalobos Mar 24 '12 at 05:47
  • Thanks for the replay. The link that helps the most is http://sitaramc.github.com/gitolite/moveserver.html. I had to checkout the latest gitolite to use the command gl-admin-push. The job is done... thanks – jeremyvillalobos Mar 24 '12 at 05:55
  • @user1052943: excellent. I have included that process in the answer for more visibility. – VonC Mar 24 '12 at 09:01
  • The http://sitaramc.github.com/gitolite/moveserver.html is no longer a valid link. Does anyone know of a mirror of this content? – Joe J Jun 25 '12 at 16:59
  • @JoeJ I have restored the links. Note that they are for Gitolite V2 or 'g2'. If you start with Gitolite now, considering installing gitolite V3 or 'g3' from the start. – VonC Jun 25 '12 at 18:33
  • Here is the link : https://gitolite.com/gitolite/install#moving-servers – M-Jack Dec 15 '21 at 18:38
  • @M-Jack I agree. I already updated the answer with that link. – VonC Dec 15 '21 at 23:32
  • Are these instructions still valid? Specifically: I added the line "exit 1;" at the top of my ~/.gitolite.rc file, but I can still push to the old server. – ygramoel Jun 28 '23 at 09:14
  • @ygramoel The [`.rc` file](https://gitolite.com/gitolite/rc.html) is part of the service account (typically `git`) which runs Gitolite. So make sure your `~` matches the account with which you have installed Gitolite. – VonC Jun 28 '23 at 09:33