You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
现在,可以通过git clone命令克隆远程仓库了,在各自的电脑上运行 $ git clone git@server:~/sample.git Cloning into 'sample'...warning: You appear to have cloned an empty repository.
1、安装git
$ sudo apt-get install git
2、创建一个git用户,用来运行git服务
$ sudo adduser git
3、创建证书登录
收集所有需要登录的用户的公钥,就是他们自己的id_rsa.pub文件,把所有公钥导入到/home/git/.ssh/authorized_keys文件里,一行一个。
4、初始化Git仓库
先选定一个目录作为Git仓库,假定是sample.git,在~目录下输入命令:
$ git init --bare sample.git
5、禁用shell登录
出于安全考虑,第二步创建的git用户不允许登录shell,这可以通过编辑/etc/passwd文件完成。找到类似下面的一行:
git:x:1001:1001:,,,:/home/git:/bin/bash
改为
git:x:1001:1001:,,,:/home/git:/usr/bin/git-shell
6、克隆远程仓库
现在,可以通过git clone命令克隆远程仓库了,在各自的电脑上运行
$ git clone git@server:~/sample.git
Cloning into 'sample'...warning: You appear to have cloned an empty repository.
The text was updated successfully, but these errors were encountered: