官术网_书友最值得收藏!

Trying out Gitolite

It's very easy to try out Gitolite in a safe environment without affecting anything else in the system in any permanent manner. Gitolite has a fairly complete set of test scripts, and the officially supported method of trying out Gitolite simply uses a couple of these test scripts to automatically install and set up Gitolite.

At the end of this process, you will have a version of Gitolite all set up and ready to use. You will also have an "admin" user, and six "normal" users, using which you can try out most of the features of Gitolite (with the exception of some advanced features such as mirroring).

Preparing for the setup

You will need the following in order to try out Gitolite:

  • A Unix (Linux, BSD, HP-UX, AIX, Solaris, and so on) server
  • Git version 1.7.1 or later installed on the server
  • Perl 5.8.8 or later version installed on the server
  • An OpenSSH-compatible SSH daemon installed and running on the server
  • Root access to the server in order to create a new throw away user to do the testing in

At the time of writing this book, Git 1.7.1 is over three years old, and Perl 5.8.8 is quite a bit older than that, so almost any recent Linux or BSD system should work fine.

Installing and setting up a test instance

With the prerequisites at hand, here's how you would get yourself a test instance of Gitolite to try out:

  1. Log in as root (using whatever commands your OS/distro requires to do that) and create a new throw away user. You can call this anything you want, but we will use the name gitolite-test here. Please do not use an existing user for this!
  2. Log in as the gitolite-test user.
  3. Get the Gitolite sources from the official repository, git clone git://github.com/gitolite/gitolite.

    You can get this from any other clone of the gitolite sources if your server cannot directly access the internet. Just substitute the URL you have in the preceding clone command.

  4. Switch to the directory that was just cloned using the following command:
    cd gitolite
    
  5. Install and set up Gitolite in test mode using the following command:
    env GITOLITE_TEST=y prove t/ssh*
    
  6. Go back to the HOME directory:
    cd
    

This will churn through two of the test scripts. You will see a warning about an authorized_keys file being created, which you can ignore, and finally a message saying All tests successful, with some statistics on the test run.

At the end of that process, you should have the following: one "admin" user (called admin) and six normal users (named u1 through u6). These users are simulated using an ssh feature. If you are familiar with ssh, you can look in ~/.ssh/config to see how this is done.

Playing with Gitolite

You can now use the test setup of gitolite from the previous section. Here's a sample set of commands with notes to start you off:

Clone the special gitolite-admin repository:

$ git clone admin:gitolite-admin 
Cloning into 'gitolite-admin'... 
remote: Counting objects: 8, done. 
remote: Compressing objects: 100% (4/4), done. 
remote: Total 8 (delta 1), reused 0 (delta 0) 
Receiving objects: 100% (8/8), done. 
Resolving deltas: 100% (1/1), done. 

Examine the contents of the clone:

$ cd gitolite-admin/ 
$ ls -a 
. .. conf .git 
$ ls -a conf 
. .. gitolite.conf 

Edit the conf/gitolite.conf file and add the following lines, which tell Gitolite to create a new repository called bar and allow users u1 and u2 all rights to it:

repo bar
 RW+ = u1 u2

Save the file, then add the change (git add) and commit the file (git commit):

$ git add conf/gitolite.conf 
$ git commit -m 'added repo bar' 
[master 1111cee] added repo bar 
 1 file changed, 3 insertions(+) 
$ git push 
Counting objects: 7, done. 
Delta compression using up to 4 threads. 
Compressing objects: 100% (2/2), done. 
Writing objects: 100% (4/4), 338 bytes | 0 bytes/s, done. 
Total 4 (delta 1), reused 0 (delta 0) 
remote: Initialized empty Git repository in /home/gitolite-test/repositories/bar.git/ 
To admin:gitolite-admin 
 f226f28..1111cee master -> master

As you can see, we've just created a new repository called bar. If you look at the output carefully, you might notice, among the familiar output of a git push command, a line saying that an empty Git repository was initialized on the server. This is useful because you don't have to log on to the server to create the repository—Gitolite takes care of it.

Let's look at some access rights. Running ssh against the server and supplying info as the command will show you what repositories you have access to:

$ ssh admin info 
hello admin, this is gitolite-test@server running gitolite3 v3.5.3.1-6-g5bdc750 on git 1.8.3.1 

 R W gitolite-admin 
 R W testing 
$ ssh u1 info 
hello u1, this is gitolite-test@server running gitolite3 v3.5.3.1-6-g5bdc750 on git 1.8.3.1 

 R W bar 
 R W foo 
 R W testing 
$ ssh u3 info 
hello u3, this is gitolite-test@server running gitolite3 v3.5.3.1-6-g5bdc750 on git 1.8.3.1 

 R W foo 
 R W testing 

The preceding command shows you a list of the repositories you have access to, and for each of them, whether you can read and write to the repository, or you have read-only access.

Tip

A note on command and URL syntax

Remember that we are running the Gitolite server, as well as simulating the seven different users, on the same Unix user (which is gitolite-test). As a result, you are able to use commands such as git clone admin:gitolite-admin and ssh u1 info. In a real setup, you will represent yourself, and the server will be elsewhere. The commands will be of the form git clone gitolite-test@server:gitolite-admin and ssh gitolite-test@server info.

主站蜘蛛池模板: 集贤县| 夏邑县| 仪陇县| 梨树县| 望江县| 南溪县| 文登市| 武强县| 西乡县| 安丘市| 丹阳市| 肇源县| 天水市| 湛江市| 黑山县| 平安县| 寿宁县| 高平市| 襄樊市| 天津市| 丰顺县| 大兴区| 无棣县| 广西| 景德镇市| 文昌市| 出国| 广元市| 化州市| 永平县| 怀安县| 海林市| 淄博市| 林州市| 南华县| 霍林郭勒市| 通辽市| 萍乡市| 辉县市| 庐江县| 金溪县|