Moving existing local GIT repository into a fresh gitolite setup

One of the tools I use is gitolite, a nice solution for hosting GIT repositories with privileges control and many more. Installation is trivial, just follow the tutorial instructions.
Let’s say you already have local repository and start to use gitolite on a remote server. This may happen when changing servers, git hosting provider etc. How to safely transfer your project? Firstly, you have to create new (usually bare) repository. In gitolite you just add to gitolite-admin/conf/gitolite.conf something similar:

repo    test_repository
        RW+     =   user

Then go to your local working copy and type:

$ git remote
origin

This will show you all remote repositories that you used to connect with. In my case there was only “origin”, and it was the exact one I wanted to replace. With following commands you remove existing repository:

$ git remote rm origin

and add a new one:

$ git remote add origin gitolite@example.com:test_repository.git

What will show more verbose version of “git remote” now?

$ git remote -v
origin  gitolite@example.com:test_repository.git (fetch)
origin  gitolite@example.com:test_repository.git (push)

That’s it. Now you can send your data to server:

$ git push origin master

Because it is very first “push” into an empty repo, you must explicitly point which remote and what branch you are sending data to. This will be remembered as default, so you don’t need to type it anymore. The same applies to the first “pull” or “fetch”:

$ git pull origin master

21. October 2011 by resset
Categories: Software | Tags: , | 4 comments

Comments (4)

  1. Pingback: Setting up a gitolite server in Ubuntu | Marian Schedenig's Website

  2. Pingback: git | Pearltrees

Leave a Reply

Required fields are marked *