gitolite_如何设置Gitolite Git服务器-十分钟教程

gitolite

I ever introduced seting up git server using SSH or gitosis. However, gitolite is the way to go for managing git servers if you want an lightweight authentication layer. gitolite provides many very usefull features which can control each user’s right on each branch. I set up one gitolite git server and am very happy with it. In this post, let’s look at how to set up one gitolite git server. I aim to provide a ten-minute tutorial, and hence, will make the process straightforward, just to the point and as automatic as possible: 1 variable setting, 2 commands with twice asking root password are all steps needed.

我曾经介绍过使用SSHgitosis设置git服务器。 然而, gitolite要走的路管理git的服务器,如果你想要一个轻巧的验证层。 gitolite提供了许多非常有用的功能,可以控制每个分支上每个用户的权限。 我设置了一台gitolite git服务器,对此感到非常满意。 在本文中,让我们看一下如何设置一个gitolite git服务器。 我打算提供一个十分钟的教程,因此,将使该过程变得直截了当,直截了当并尽可能自动:1个变量设置,2个要求输入两次root密码的命令都是必需的步骤。

假设 (Assumptions )

I make some assumptions about the git server and your workstation. This should be quite common for many readers. If your environment is not like this, you need to customize the later process by yourself. Both the server and the workstation run Linux, of course. I tested on Fedora 12 and Fedora 19. The method here has minimal requirement about the Linux environment.

我对git服务器和您的工作站进行一些假设。 对于许多读者来说,这应该很常见。 如果您的环境不是这样,则需要自己定制以后的过程。 当然,服务器和工作站都运行Linux 。 我在Fedora 12和Fedora 19上进行了测试。这里的方法对Linux环境的要求最低。

关于您的git服务器 (About your git server )
  • ssh port (22).ssh端口(22)。
  • With git installed.

    与git安装。
  • Has Internet connection for cloning from github.

    具有Internet连接,可以从github进行克隆。
  • You have the root password to login as root.

    您具有root用户密码才能以root用户身份登录。

root account is needed to create the git user on the git server. If you do not have root, you can customize the following commands by deleting the step for creating the git user. Hence, after a little bit customization, this works on any server that provides ssh, git and Internet connection, such as some shared hosting with ssh enabled.

需要根帐户在git服务器上创建git用户。 如果您没有root用户,则可以通过删除创建git用户的步骤来定制以下命令。 因此,在进行一些自定义之后,它可以在任何提供ssh,git和Internet连接的服务器上工作,例如某些启用了ssh的共享主机

关于您的工作站 (About your workstation )
  • ssh-keygen.ssh-keygen生成一个。
  • You are using bash and you have git, ssh and scp installed on the workstation.

    您正在使用bash,并且在工作站上安装了git,ssh和scp。

设置gitolite git服务器 (Set up the gitolite git server )

Now, let’s start to set the gitolite git server. The following steps is done in one terminal on your workstation.

现在,让我们开始设置gitolite git服务器。 在工作站的一个终端上完成以下步骤。

收集信息 (Collect the information )

First, let’s collect some information about the git server and your workstation:

首先,让我们收集有关git服务器和工作站的一些信息:

  • $GIT_SERVER).$GIT_SERVER )。
  • $GIT_USER, usually git) on the git server for storing repositories.$GIT_USER ,通常是git)。
  • $ADMIN, you can use just your login username on your workstation) that you want to use as the administrator.$ADMIN ,您只能在工作站上使用您的登录用户名)。
  • Your public key ($ADMIN_KEY, usually ~/.ssh/id_rsa.pub) for the git repository management.

    您用于git信息库管理的公共密钥( $ADMIN_KEY ,通常是~/.ssh/id_rsa.pub )。

Usually, you only need to change the $GIT_SERVER in the following commands. Run thee commands:

通常,您只需要在以下命令中更改$GIT_SERVER 。 运行命令:

GIT_SERVER=example.com
GIT_USER=git
ADMIN=$USER
ADMIN_KEY=$HOME/.ssh/id_rsa.pub

将您的公钥复制到git服务器 (Copy your public key to the git server )

You will need to input the root’s password.

您将需要输入根用户的密码。

scp $ADMIN_KEY root@$GIT_SERVER:/tmp/$ADMIN.pub
ssh root@$GIT_SERVER chmod 777 /tmp/$ADMIN.pub

在git服务器上设置gitolite环境 (Set up the gitolite environment on the git server )

You will need to input the root’s password.

您将需要输入根用户的密码。

ssh root@$GIT_SERVER "adduser $GIT_USER; su $GIT_USER -c \
\"wget https://raw.githubusercontent.com/zma/usefulscripts/master/script/install-gitolite.sh -O /tmp/install-gitolite.sh && sh /tmp/install-gitolite.sh /tmp/$ADMIN.pub\""

This command ssh to the git server as root and does the follows. First, as root, create the user for hosting git. Then, as the git user, clone the gitolite from github, install it to ~/bin/ and set up the gitolite.

此命令以root身份ssh到git服务器,并执行以下操作。 首先,以root身份创建用于托管git的用户。 然后,作为git用户,从github克隆gitolite,将其安装到〜/ bin /并设置gitolite。

If everything goes well, you will see output as follows

如果一切顺利,您将看到如下输出

--2015-06-03 14:26:03--  https://raw.githubusercontent.com/zma/usefulscripts/master/script/install-gitolite.sh
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 103.245.222.133
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|103.245.222.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 448 [text/plain]
Saving to: ‘/tmp/install-gitolite.sh’

     0K                                                       100%  109M=0s

2015-06-03 14:26:03 (109 MB/s) - ‘/tmp/install-gitolite.sh’ saved [448/448]

Cloning into 'gitolite'...
Initialized empty Git repository in /home/git/repositories/gitolite-admin.git/
Initialized empty Git repository in /home/git/repositories/testing.git/

And the gitolite git server is set up successfully.

并成功建立了gitolite git服务器。

测试gitolite git服务器 (Test the gitolite git server )

You can test the gitolite git server with the default testing repository provided by gitolite:

您可以使用gitolite提供的默认测试存储库来测试gitolite git服务器:

git clone $GIT_USER@$GIT_SERVER:testing

You can edit, commit and push in the testing repository. If you are not familiar with git, you can check Howto for New Git Users for some help.

您可以编辑,提交和推送测试存储库。 如果您不熟悉git,可以查看How to New Git Users以获得帮助。

管理gitolite git服务器 (Managing the gitolite git server )

Management of the gitolite git server is through the gitolite-admin repository, which is similar to managing gitosis git servers. You can clone the gitolite-admin repository:

通过gitolite-admin存储库管理gitolite git服务器,这类似于管理gitosis git服务器 。 您可以克隆gitolite-admin存储库:

git clone $GIT_USER@$GIT_SERVER:gitolite-admin

示例任务 (An example task )

To give you a brief understanding of how to manage the repositories of the gitolite git server, let’s do one task: create a new repository example-repo, add a new user alice (public key: alice.pub) and give alice read/write/delete access to the repository example-repo.

为了让您简要了解如何管理gitolite git服务器的存储库,让我们做一个任务:创建一个新的存储库example-repo,添加一个新的用户alice(公共密钥:alice.pub)并给alice读/写。 /删除对存储库example-repo的访问。

The commands to do this (replace /path/to/alice.pub with the actual address) are as follows.

为此的命令(将/path/to/alice.pub替换为实际地址)如下。

cd gitolite-admin
cp /path/to/alice.pub to keydir/
echo "repo example-repo
    RW+     =   alice
" >> conf/gitolite.conf

git add keydir/alice.pub
git commit -a -m 'add alice; add example-repo'; git push

The new repository is created for alice. You can print out the repository address:

为爱丽丝创建了新的存储库。 您可以打印出存储库地址:

echo "$GIT_USER@$GIT_SERVER:example-repo"

For more controls and rules supported by gitolite, you can check the gitolite manual.

有关gitolite支持的更多控件和规则,请查看gitolite手册

What’s next step? The first step after setting up a git server is usually setting up email notifications: Setting Up Git Commit Email Notifications.

下一步是什么? 设置git服务器后的第一步通常是设置电子邮件通知: 设置Git提交电子邮件通知

翻译自: https://www.systutorials.com/how-to-set-up-gitolite-git-server-a-ten-minute-tutorial/

gitolite

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值