准备环境
IP | 主机名 |
---|---|
192.168.47.126 | server |
192.168.47.125 | client |
需求
下载源码包编译安装或者yum安装
服务端创建git用户,配置空仓库
创建无秘钥登录证书
客户端命令使用:克隆、修改git配置、 添加修改文件到暂存区、 提交修改到本地仓库、 提交修改到远程服务器。
1.yum安装git
yum -y install git
2.创建git用户
[root@server ~]# useradd -m git
[root@server ~]# passwd git
Changing password for user git.
New password:
BAD PASSWORD: The password is a palindrome
Retype new password:
passwd: all authentication tokens updated successfully.
3.创建空仓库
[root@server ~]# su - git
[git@server ~]$ mkdir project.git
[git@server ~]$ cd project.git/
[git@server project.git]$ git init --bare
Initialized empty Git repository in /home/git/project.git/
4.仓库文件授权
[git@server project.git]$ chown -R git:git /home/git/project.git/
5.客户端访问方式
[root@server ~]# git clone file:///home/git/project.git/
Cloning into 'project'...
warning: You appear to have cloned an empty repository.
[root@client ~]# git clone git@192.168.47.126:/home/git/project.git
Cloning into 'project'...
The authenticity of host '192.168.47.126 (192.168.47.126)' can't be established.
ECDSA key fingerprint is 85:fd:a6:6f:4a:35:f3:9f:14:d9:1c:97:44:db:a3:f9.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.47.126' (ECDSA) to the list of known hosts.
git@192.168.47.126's password:
warning: You appear to have cloned an empty repository.
6.创建无密钥登陆证书
(服务端、客户端都要执行)
[root@server ~]# su - git
[git@server ~]$ ll
total 0
[git@server ~]$ pwd
/home/git
[git@server ~]$ ssh