Git安装与使用

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

图片[1]- FBIKIMGit安装与使用- FBIKIM

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

配置文件权限:

图片[2]- FBIKIMGit安装与使用- FBIKIM

方法二:

ssh-keygen

图片[3]- FBIKIMGit安装与使用- FBIKIM

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

图片[4]- FBIKIMGit安装与使用- FBIKIM

su – git

mkdir .ssh

chmod 700 .ssh/

vi .ssh/authorized_keys (服务器端存放id_rsa.pub公钥)

chmod 600 .ssh/authorized_keys

图片[5]- FBIKIMGit安装与使用- FBIKIM

测试免密钥拉去仓库项目

图片[6]- FBIKIMGit安装与使用- FBIKIM

客户端节点克隆项目

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”

© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享
评论 抢沙发
头像
欢迎您留下宝贵的见解!
提交
头像

昵称

取消
昵称表情代码图片