LAN 上的 GIT 存储库

14 git

我正在尝试在Ubuntu操作系统中通过 LAN设置一个GIT 存储库。 我能够设置一个 GIT 存储库,但不确定如何将存储库公开给 LAN 中的其他用户。 由于它需要一个服务器,我安装了OpenSSH-Server。但不知道如何配置它。 请指出我要阅读的正确资源。 谢谢。




Von*_*onC 17

首先,您需要检查 Ubuntu 服务器上的 openssh 设置:请参阅此 HowTo

那你可以关注这篇文章,主要推荐:

$ sudo apt-get install python-setuptools
$ mkdir ~/src
$ cd ~/src
$ git clone git://eagain.net/gitosis.git
$ cd gitosis
$ sudo python setup.py install
$ sudo adduser \
  --system \
  --shell /bin/sh \
  --gecos 'git version control' \
  --group
  --disabled-password \
  --home /home/git \
  git
Run Code Online (Sandbox Code Playgroud)

进入您的/etc/ssh/ssh_config文件并将 git 添加到可以登录的允许用户列表中。
将您的id_rsa.pub文件复制到您的服务器某处(在我们的示例中我们正在使用/tmp),然后运行以下命令:

 $ sudo -H -u git gitosis-init < /tmp/id_rsa.pub
     Initialized empty Git repository in ./
 $ sudo chmod 755 /home/git/repositories/gitosis-admin.git/hooks/post-update
Run Code Online (Sandbox Code Playgroud)

在你的本地机器上,用这个测试一下:

 git clone git@YOUR_SERVER:gitosis-admin.git
Run Code Online (Sandbox Code Playgroud)

为新项目配置 gitosis。使用您最喜欢的编辑器在 gitosis 下创建一个新块。它应该是这样的:

[group myrailsapp]
members = myNameAsInTheRsa.pub
writable = myNewApp
Run Code Online (Sandbox Code Playgroud)

在上面的块中有几件事情需要注意。
首先,确保您的姓名与您的公钥中的内容匹配(即,打开您的 id_rsa.pub 文件并查看名称的内容。
第二,确保您拼写正确!

完成后,提交更改并将更改推送到服务器。

$ git commit -a -m "created a new repository!"
$ git push
Run Code Online (Sandbox Code Playgroud)