Document directory
- 1. Install git
- 2. Install gitosis
- 3. Generate a Public Key
- 4. Upload the Public Key
- 5. Generate a management database on the server
- 6. Synchronize the configuration file
- 7. Create a new repositories
Use gitosis to configure and manage git servers
Reprinted: http://blog.prosight.me/index.php/2009/07/271
1. Install git
-
- Emerge-AV Dev-util/git
-
2. Install gitosis
The GIT environment can be directly used by default, but you need to open an SSH permission account for each member, and cross-permission management between each warehouse is very troublesome, so you need to use gitosis, it does not require an SSH account for every developer, which is secure and convenient.
-
- Emerge-AV gitosis
-
If you are prompted that the package is mask, edit the/etc/portage/package. Keywords file and add
-
- Dev-util/gitosis ~ Amd64
-
3. Generate a Public Key
Use on the client
-
- Ssh-keygen-T RSA
-
To generate an SSH key. Note that your host name must contain all English characters and cannot contain special characters such as underlines or.. Otherwise, an error will be reported when the server generates a version library.
4. Upload the Public Key
Upload the generated public key from the client to the server.
-
- SCP~ /.SSH/Id_rsa.pub user @ your_server:/tmp
-
5. Generate a management database on the server
-
- Sudo-H-u git gitosis-init </tmp/id_rsa.pub
-
If it succeeds, you will see a message similar to the following:
-
- Initialized empty git repository in/var/spool/gitosis/repositories/gitosis-admin.git/
- Reinitialized existing git repository in/var/spool/gitosis/repositories/gitosis-admin.git/
-
Set post-update script Permissions
-
- Chmod755/var/spool/gitosis/repositories/gitosis-admin.git/hooks/post-Update
-
Now, the server configuration has been completed.
6. Synchronize the configuration file
Gitosis itself is a git library, so it is very convenient to manage. The following figure shows how to synchronize the gitosis management library on the client.
-
- Git clone git @ your_server: gitosis-admin.git
- CD gitosis-Admin
-
You will see the following files
-
- -RW-r-1 Garry 104 Nov 13 gitosis. conf
- Drwxr-XR-x 3 Garry 102 Nov 13 keydir/
-
Gitosis. conf is the configuration file of gitosis for configuring users and permissions.
Keydir/is the public key of all group members
We can modify the configuration locally and change the permission. After the permission is pushed to the server, the server takes effect immediately.
7. Create a new repositories
Open the gitosis. conf file and you will see
-
- [Group gitosis-admin]
- Writable = gitosis-Admin
- Members = Elton @ MacBook
-
This is the Management Group permission. The username in members is the username in the uploaded public key.
Add the following content to the file:
-
- [Group myteam]
- Members = Elton @ MacBook
- Writable = free_monkey
-
Here you define a group named myteam and grant the repo permission to the Elton @ MacBook user to write "free_monkey ".
-
- Git commit-a-m "allow Elton write access to free_monkey"
- Git push
-
The above operation updates the server's permissions.
Create a repo for free_monkey.
-
- MkdirFree_monkey
- CD free_monkey
- Git init
-
Create a. gitignore file to ignore some content that does not require code management. For example, the rails application may be as follows:
-
- . Ds_store
- Log/*. Log
- TMP /**/*
- Config/database. yml
- DB/*. sqlite3
-
Code submission:
-
- Git remote add origin git @ your_server_hostname: free_monkey.git
- Git add.
- Git commit-a-m "Initial import"
-
- Git push origin master: refs/heads/Master
-
Next, you can add the Member's public key to the system.
-
- CD gitosis-Admin
- CP~ /Alice. Pub keydir/
- CP~ /Bob. Pub keydir/
- Git add keydir/Alice. Pub keydir/Bob. Pub
-
Modify gitosis. conf
-
- [Group myteam]
- -Members = jdoe
- + Members = jdoe Alice Bob
- Writable = free_monkey
-
Submit changes:
-
- Git commit-a-m "granted Alice and Bob commit rights to freemonkey"
- Git push
-
Other members can get the code.
-
- Git clone git @ your_server: free_monkey.git
-