一、安装
sudo yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel sudo yum install gcc perl-ExtUtils-MakeMaker
安装 sudo wget https://github.com/git/git/archive/v2.9.2.tar.gz sudo tar -zvxf v2.9.2.tar.gz cd git-2.9.2 sudo make prefix=/usr/local/git all sudo make prefix=/usr/local/git install
将git设置为默认路径,不然后面克隆时会报错 sudo ln -s /usr/local/git/bin/git-upload-pack /usr/bin/git-upload-pack sudo ln -s /usr/local/git/bin/git-receive-pack /usr/bin/git-receive-pack
添加git用户和用户组用来运行git服务
代码语言:javascript复制sudo groupadd git
sudo useradd git -g git
sudo passwd git
su - git
二、创建证书登录
代码语言:javascript复制cd /home/git
mkdir .ssh
chmod 700 .ssh
touch .ssh/authorized_keys
chmod 600 .ssh/authorized_keys
将公钥导入到authorized_keys
初始化Git仓库
代码语言:javascript复制cd /data
mkdir gitrepo
chown git:git gitrepo/
cd gitrepo
git init --bare starins.git
chown -R git:git starins.git
三、使用
git clone ssh://git@ip:port/data/gitrepo/starins.git