Dec 1, 2012

Migrating and transfering gitolite to a new server

I am going to assume you have already installed gitolite on two servers (if you haven't, check out my guide on installing gitolite). This post will outline how you will move your repositories from one server to your new one.

The server side

  1. You can edit some of the configuration files stored in the home directory of the gitolite user. You only have to do this step if you have an unusual set-up; it should work fine if you did a default install.
  2. Copy the contents of your repositories folder to the new server (except gitolite-admin; we will do this at a later stage). Use either the commands cp or scp. For instance:
    scp -r repo.git/ root@192.168.0.1:/var/lib/gitolite/repositories/
  3. Change the owner and group of the copied repositories:
    chown -R gitolite:gitolite repo.git/
  4. Clone the gitolite configuration repository on your administration machine:
    git clone gitolite@192.168.0.1:gitolite-admin.git
  5. Add the keys and configuration files from your old repository and place them into your new repository. Do a commit and then a push:
    git add .
    git commit -as
    git push
  6. The server is now set up and ready to use! Optional: The guide quoted that you may need to run gl-setup again once the repositories have been copied across, but I didn't need to. You may want to do that step....

The client side

To point your git repository to the new server (so you don't have to reconfigure your IDE or scripts) just run the following commands:

git remote rename origin old
git remote add origin git@192.168.0.1:repo.git
git remote -v
git remote rm old

Further Reading: