Team: git with multi-user

git…gitolite…it is an important tool to development, but require some patience to setup.

No much neat tutorial written on web. I write mine.

1. Prepare a few things before start:

  • ssh login
  • all public key of users
  • repository hierarchical structure design

2. Install gitolite (previously gitosis)
$ apt-get install gitolite

3. Create a single user for the gitolite account
$ adduser gitolite

4. Run setup with gitolite user, providing the admin public key
$ su - gitolite
$ gl-setup your_key.pub

5. Server is setup. Next, configure it.
Go back to client. Clone the admin folder. This will work fine if you do the steps correctly.
$ git clone gitolite@server.com:gitolite-admin

6. Goto gitolite-admin
$ cd gitolite-admin

7. The folder has two subfolders. “conf" and “keydir".
What you have to do is to put all the user’s public key into the “keydir" folder, and then edit the file in conf/gitolite.conf.

8. The file is like this:
repo gitolite-admin
RW+ = admin

repo testing
RW+ = @all

repo repo-A
RW+ = admin
RW+ = userA

The name (admin, userA, etc..) is referring to the filename public keys in the “keydir" folder. The keyword “repo" refers to a new repository. If you add a new repo with the same format, the server will create repository accordingly. I create a new repo named repo-A in above file.

9. After changing the conf/gitolite.conf file, git-commit it.
$ git add .
$ git commit -a -m "commit"
$ git push origin master

The server settings are automatically updated after commit.

10. Now you can git clone the new repo. e.g. repo-A
$ git clone gitolite@server.com:repo-A

Done~

p.s.
The authentication part, individual user need not to have access right to the server where the gitolite is hosted. Just don’t put the public key into ~/.ssh folder, only put them in the keydir of gitolite-admin.
This tutorial is a bit complex, but much simpler than those available on other place now which I learn the tools from.

Cheers~

發表留言