centos7下yum源安装git

ip 主机名 备注
172.16.121.68 git 服务端
172.16.121.69 git-con 客户端

需求:
下载源码包编译安装或者yum安装
服务端创建git用户,配置空仓库
创建无秘钥登录证书
客户端命令使用:克隆、修改git配置、 添加修改文件到暂存区、 提交修改到本地仓库、 提交修改到远程服务器。
1.安装git
在这里插入图片描述
在这里插入图片描述
2.创建无密钥登入
在这里插入图片描述在这里插入图片描述
把git-con的公钥加入到git 的/home/git/.ssh/authorized_keys中

[root@git-con ~]# cat /root/.ssh/id_rsa.pub 
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC8zsUIqG/pc27LzuFqxqeIjk54NQlb4q3OjzF2JRQDsIfwFdmr4xeQJhw08EnmIENf/syfGFhwkM1gBxBBoGK5FANKBqXo2ZxrdkKxshjE0CbRXDjiheN1ztu/xkV2g2UDXPRI+tGomywzz/LJMpwG3wZ2OWpMNNj8UVtzI6klT4sW/Q/CsiwbqTuPGM+meWA4aDddse1gUz3VwalUhhYKS3y46WUrWUhs3hIoUmnKDuTf0aLYNzLV5UCi2zbRjnvQizYTQ6bEd6Nq5+oT1Mo6i8i39ELzdeX4aekfSO/f3Ms4SoUJd4Krop6rF2YA6kQmOr3ERSyrtclw+GApFIWj root@git-con
[root@git ~]# vi /home/git/.ssh/authorized_keys 
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDQshup9DnEQuUGUxzYINKBC9BfsG32DFIvOBGf5ku75++qprFqAqdAiAXvUzVVpDVD2xLOb3LA3r6yf5jkUGWIzunt+8mVGlpw8zCfEtfkurV0mdP6nqXpAAJVyaIXVt88g4+ROY17M76LOT96cFO7vhKfKkzT5J5NKR/kR5ySuEIECF7dxlvdKR7fYGylh+a5eKH
DLQot8svBKiMgs2+N5Tmy0XqgvBF0/tbzbYESp0hxXinCcoAKrHrYoSG1MrIMk6vW9Ez9+gArLe4COefP+ECfZoxOvbPQ/RrxRUuaYC4rI2OkPnAh49jDEOTssLP8spKswpPUSH4Vef0P61Id git@git
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC8zsUIqG/pc27LzuFqxqeIjk54NQlb4q3OjzF2JRQDsIfwFdmr4xeQJhw08EnmIENf/syfGFhwkM1gBxBBoGK5FANKBqXo2ZxrdkKxshjE0CbRXDjiheN1ztu/xkV2g2UDXPRI+tGomywzz/LJMpwG3wZ2OWpMNNj8UVtzI6klT4sW/Q/CsiwbqTuPGM+meWA4aDd
dse1gUz3VwalUhhYKS3y46WUrWUhs3hIoUmnKDuTf0aLYNzLV5UCi2zbRjnvQizYTQ6bEd6Nq5+oT1Mo6i8i39ELzdeX4aekfSO/f3Ms4SoUJd4Krop6rF2YA6kQmOr3ERSyrtclw+GApFIWj root@git-con

测试
在这里插入图片描述
可以免密登入完成

3.客户端命令

clone 将远程服务器仓库克隆到本地
config 修改git配置
add 添加修改文件到暂存区
commit 提交修改到本地仓库
push 提交修改到远程服务器

克隆:
在这里插入图片描述
在这里插入图片描述
修改git配置:
git config --global --list # 查看全局配置
git config --global user.name hoby # 修改提交名
git config --global alias.br branch # 修改简写
git config --unset alias.co # 删除配置项
git config --global core.ignorecase false # 关闭忽略大小写
对大数据进行修改:

[root@git-con wjh]# echo "wjh" > 1.html
[root@git-con wjh]# git add .     添加修改文件到暂存区
[root@git-con wjh]# ll
total 4
-rw-r--r--. 1 root root 4 Mar 16 18:27 1.html
[root@git-con wjh]# git commit -m "wjh"   

*** Please tell me who you are.

Run

  git config --global user.email "[email protected]"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address (got 'root@git-con.(none)')
[root@git-con wjh]# git config --global user.name "users"
[root@git-con wjh]# git config --global user.email "[email protected]"
[root@git-con wjh]# git commit -m "wjh"     将暂存区里的改动给提交到本地的版本库
[master (root-commit) d86ea46] wjh
 1 file changed, 1 insertion(+)
 create mode 100644 1.html
[root@git-con wjh]# git remote add origin [email protected]:/home/git/wjh.git
fatal: remote origin already exists.
[root@git-con wjh]# git push origin master 
Counting objects: 3, done.
Writing objects: 100% (3/3), 201 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To [email protected]:/home/git/wjh.git/
 * [new branch]      master -> master

查看仓库数据状态:

在这里插入图片描述

发布了25 篇原创文章 · 获赞 0 · 访问量 678

猜你喜欢

转载自blog.csdn.net/miss_miss6/article/details/104910614