vmware 准备3个服务器
192.168.5.136 docker、jenkins
192.168.5.137 docker、
192.168.5.138 docker、
192.168.5.139 docker、git、registry
1、Git安装,可通过
多种方式,可下安装包。
这里直接yum 安装
yum install git -y
2、创建Git用户并设置密码
-- 新增用户gitu useradd gitu -- 设置用户gitu的密码 passwd gitu
3、创建Git仓库
-- 切换用户为gitu su - gitu -- 创建空文件夹 mkdir hello.git -- 进入文件夹 cd hello.git --初始化文件夹为git仓库 git --bare init
4、访问Git仓库,并提交信息到git库
# git clone https://github.com/b3log/solo
# cd hello 移除旧的推送地址,添加新的: # git remote remove origin # git remote add origin [email protected]:/home/gitu/solo.git 提交代码到Git仓库并创建tag: # touch src/main/webapp/a.html # git add . # git commit -m “a” 创建标签: # git tag 1.0.0 推送到Git服务器: # git push origin 1.0.0
5、克隆git仓库
-- 克隆下载gitu用户,仓库地址为192.168.5.139下的/home/gitu/hello.git,如果没做机器免密就需要输入密码 git clone gitu@192.168.5.139:/home/gitu/hello.git
6、SSH免密登录。
原理:每台机器都生成ssh密钥信息,将客户机的公钥信息,放在自己机器上,客户机来访问,比对公钥,如果一致怎无需密码验证。
参考:https://blog.51cto.com/lizhenliang/2159817