1、安装git (仓库Server与用户端都需要装)
yum install git -y
2、创建用户 git
useradd git
passwd git
3、切换到git用户
su – git
mkdir app.git && cd app.git
4、初始化仓库
git –bare init
配置仓库权限给git用户
chmod 777 /opt/app.git

5、测试克隆项目
git clone git@192.168.1.100:/home/git/app.git
6、创建测试页面
touch index.html
7、配置提交的用户
git config –global user.name “Your name”
git config –global user.email you@abc.com
8、先添加到本地仓库,再提交到云端仓库
git add .
git commit -m “注释”
9、配置服务器免交互认证密钥对
方法一:
ssh-keygen
ssh-copy-id root@192.168.1.100
配置文件权限:

方法二:
ssh-keygen

将 ~/.ssh/id_rsa.pub 公钥上传至服务器端家路径目录

su – git
mkdir .ssh
chmod 700 .ssh/
vi .ssh/authorized_keys (服务器端存放id_rsa.pub公钥)
chmod 600 .ssh/authorized_keys

测试免密钥拉去仓库项目

客户端节点克隆项目
git clone git@192.168.1.100:/opt/app.git
cd app
echo 123 > index.html
git add .
git status
git config –global user.email “you@example.com”
git config –global user.name “Your Name”
git commit -m “test index”