How to move git repositories from github to local server running gitolite

git, gitolite

Solution

Add the new repo in gitolite-admin/conf/gitolite.conf

repo my-new-repo
    RW+            = your-user

Add, commit and push the changes into gitolite-admin

git add conf/gitolite.conf
git commit -m "Added my-new-repo"
git push origin

Clone your github repo and checkout all the branches present

git clone github.com:/USERNAME/YOUR_REPO.git
cd YOUR_REPO
for branch in `git branch -a | grep remotes | grep -v HEAD | grep -v master`; do     git branch --track ${branch##*/} $branch; done

Remove the github remote, and add your gitolite remote:

git remote rm origin
git remote add origin YOURSERVER:my-new-repo.git

Push all the refs onto the repo managed by gitolite:

git push --all origin

I verified the steps in a test repository of mine, and all the refs seem to have propagated into the new repo.

UPDATE: Like Seth pointed out, any other refs other than branches are not propagated to the new repo. I too feel Mirror would be a better option.

Problem

I would like to know the preferable way to move all my git repositories currently hosted on github to a new git server gitolite-based. Just for knowing, the reason why I'm doing this switch is the adoption of Redmine to support our project management process.

Original source

Related problems