git 配置gitosis
How to manage users and repositories and how to use these repositories will be introduced in this post. Please refer to Setting Up a Git Server Using Gitosis for how to set up the git server. Please refer to Howto for New Git Users for how to use git as a new user.
本文将介绍如何管理用户和存储库以及如何使用这些存储库。 请参阅“使用Gitosis设置Git服务器”以了解如何设置git 服务器 。 有关如何将git用作新用户的信息,请参考How to for New Git Users 。
创建一个新用户∞ (Create a new user ∞)
Now let’s see how to create a new user user1.
现在,让我们看看如何创建一个新用户user1。
First the new user user1 generates his/her public SSH key and copies or emails the public part of its SSH key to the administrator (we copy to /tmp/user1.pub in this example):
首先,新用户user1生成其公共SSH密钥,并将其SSH密钥的公共部分复制或通过电子邮件发送给管理员(在此示例中,我们复制到/tmp/user1.pub):
$ ssh-keygen -t rsa
$ cp ~/.ssh/id_rsa.pub /tmp/user1.pub
Then the administrator copies use1‘s public SSH key to the keydir directory in the gitosis-admin repository on the administrator’s local machine:
然后,管理员将use1的公用SSH密钥复制到管理员本地计算机上的gitosis-admin存储库中的keydir目录中:
$ cp /tmp/user1.pub keydir/
Add to the gitosis-admin repository
添加到gitosis-admin存储库
$ git add keydir/user1.pub
Commit the changes
提交更改
$ git commit -a -m 'user user1 is added'
Push to the git server
推送到git服务器
$ git push
After this administrator pushing the new commit, user1 has been added to gitosis on the git server. The name of the user’s public SSH key file is in this format:
该管理员推送新提交后,已将user1添加到git服务器上的gitosis中。 用户的公共SSH密钥文件的名称采用以下格式:
user1.pub
user1.pub
Please note that the name of the file should be the same as the user name. For example, the public key file for user1 should be user1.pub .
请注意,文件名应与用户名相同。 例如,user1的公钥文件应为user1.pub。
在配置文件∞中创建新的存储库记录 (Create a new repository record in configuration file ∞)
All the operations in this part is done by administrator on it’s local machine.
此部分中的所有操作均由管理员在本地计算机上完成。
We add a new repository named gitosis-test. In the configuration file, we add a new group gitosis-test-group and we add user1 to it’s members list. This group can write to gitosis-test repository, so that user1 can write to this repository. As described before, add these lines to gitosis.conf file:
我们添加了一个名为gitosis-test的新存储库。 在配置文件中,我们添加一个新组gitosis-test-group,并将user1添加到其成员列表中。 该组可以写入gitosis-test存储库,以便user1可以写入此存储库。 如前所述,将这些行添加到gitosis.conf文件中:
[group gitosis-test-group]
writable = gitosis-test
members = user1
We can also grant readonly access to this repository to a group of users as follows:
我们还可以向一组用户授予对此存储库的只读访问权限,如下所示:
[group gitosis-test-readonly-group]
readonly = gitosis-test
members = readuser1 readuser2
Then commit and push the changes to the server:
然后提交并将更改推送到服务器:
$ git commit -a -m 'config for new repository gitosis-test is added'
$ git push
By now, the new repository record has been added in the configuration file. User user1 is granted write privilege to it. If we want to add another user such as user2 to gitosis-test-group, just make this change:
至此,新的存储库记录已添加到配置文件中。 用户user1被授予写权限。 如果我们要将另一个用户(例如user2)添加到gitosis-test-group,只需进行以下更改:
- members = user1
+ members = user1 user2
Create and use the repository
创建和使用存储库
The user1 can create the repository by itself following the introduction in Howto for New Git Users.
用户1可以按照Howto for New Git Users中的介绍自行创建存储库。
翻译自: https://www.systutorials.com/managing-repositories-on-git-server-using-gitosis/
git 配置gitosis

747

被折叠的 条评论
为什么被折叠?



