yum install git
groupadd gitgroup
useradd gituser -g gitgroup
收集所有要登陆用户的公钥,公钥在id_rsa.pub文件中,我们把公钥保存到/home/git/.ssh/authorized_keys文件里,一行一个。 如果没有该文件,则创建它。
$ cd /home/git/
$ mkdir .ssh
$ chmod 755 .ssh
$ touch .ssh/authorized_keys
$ chmod 644 .ssh/authorized_keys
首先我们选定一个目录作为Git仓库,假定是/home/gitrepo/lichunjie.git,在/home/gitrepo目录下输入命令:
$ cd /home
$ mkdir gitrepo
$ chown gituser:gitgroup gitrepo/
$ cd gitrepo
$ git init --bare lichunjie.git
Initialized empty Git repository in /home/gitrepo/lichunjie.git/
以上命令Git创建一个空仓库,服务器上的Git仓库通常都以.git结尾。然后,把仓库所属用户改为git:
$ chown -R gituser:gitgroup lichunjie.git
$ git clone gituser@127.0.0.1:/home/gitrepo/lichunjie.git
Cloning into 'lichunjie'...
warning: You appear to have cloned an empty repository.
Checking connectivity... done.
127.0.0.1为 Git 所在服务器 ip ,你需要将其修改为你自己的 Git 服务 ip。
这样我们的 Git 服务器安装就完成。