In my previous post I outlined the steps I took to install git and gitolite on the Cubieboard, on top of Cubian X. In this guide I’ll show you what I did to:
- add a new user to my git server
- create a new empty repository
- import my existing repositories from my old Digital Ocean server
- import my GitHub repositories
How to add a new user to gitolite
- First, clone the gitolite-admin repository on your local machine, if you haven’t done so already:
git clone git@192.168.0.101:/gitolite-admin gitolite-admin-cubie
- Inside the gitolite-admin-cubie directory you should have two directories: conf and keys. To add a new user, you basically need to add her key to the keys directory. Note that you can create subdirectories under keys. Let’s assume you want to add a new user, and you have the public key: mary.pub. Note that you will use the corresponding private key to authenticate to git.
- Copy the two public key to the key folder.
- Add the key, commit the changes and push to the server:
git add keys/mary.pub git commit -m Add Mary's keys. git push origin master
Now, user Mary should be able to access the git server using her private key.
How to create a new empty repository and give rights to it
- Edit conf/gitolite.conf:
nano conf/gitolite.conf
Initial file looks something like this:
repo gitolite-admin RW+ = john repo testing RW+ = @all
To add a new repository “myapp” and give user Mary full access to it, change it to:
repo gitolite-admin RW+ = john repo testing RW+ = @all repo myapp RW+ = mary
If you want user John to have access too, do something like:
repo gitolite-admin RW+ = john repo testing RW+ = @all repo myapp RW+ = mary john
You can read a lot more about the gitolite configuration file here.
- Add, commit, and push the changes:
git add conf/gitolite.conf git commit -m "Add new myapp repo." git push origin master
Now Mary can do something like:
git clone git@192.168.0.101:/myapp
to clone the new empty repository.
How to import repositories from another server
- First, on your local machine, change the gitolite.conf file to add a new empty repository. You will import your existing repository into this new empty one.
repo gitolite-admin RW+ = john repo testing RW+ = @all repo myapp RW+ = mary john repo awesome-app RW+ = john
- Add, commit, and push the changes:
git add conf/gitolite.conf git commit -m "Add awesome-app repo." git push origin master
- On your Cubieboard, change to user git, change to the repositories folder and you should see the new empty repository awesome-app.git:
sudo su git cd /home/git/repositories ls -la
- Change to the awesome-app.git directory and import your code from your remote server:
cd awesome-app.git git --bare fetch git@existing-server.com:/awesome-app.git master:master
This assumes you already have access to your existing git server from the Cubieboard. To set that up you basically need your private key for your existing git server in /home/git/.ssh and you need to edit your /home/git/.ssh/config file adding the following lines:
Host existing-server.com Hostname existing-server.com User git IdentityFile /home/git/.ssh/existing-server-key ServerAliveInterval 300
- On your local machine you can now clone your imported repository, from your Cubieboard:
git clone git@192.168.0.101:/awesome-app
Importing GitHub repositories
Importing your GitHub repositories is similar to importing repositories from your existing server. You just need to:
- Make sure you configure GitHub access on your Cubieboard, under user git.
- On your local machine, add a new empty repository by editing gitolite.conf and pushing the changes to the Cubieboard server.
- On your Cubieboard, switch to user git, change to the new empty repository and do something like:
git --bare fetch https://username@github.com/username/repository.git master:master
If you have any questions, feel free to use the comments form below.