服务器端创建 git 用户,用来管理 Git 服务,并为 git 用户设置密码
id git
#查看是否存在此用户
useradd git
#添加用户
passwd git
#设置密码
服务器端创建一个 Git 仓库
gittest.git 为仓库名,服务器上的Git仓库通常都以.git结尾。克隆下来时 gittest 就是工作区,所以最好就是项目名。
[root@localhost home]# mkdir -p data/git/gittest.git
[root@localhost home]# git init --bare data/git/gittest.git
Initialized empty Git repository in /home/data/git/gittest.git/
[root@localhost home]# cd data/git/
[root@localhost git]# chown -R git:git gittest.git/
创建SSH Key
###当你第一次使用Git的clone或者push命令连接时,会得到一个警告:
The authenticity of host 'github.com (xx.xx.xx.xx)' can't be established.
RSA key fingerprint is xx.xx.xx.xx.xx.
Are you sure you want to continue connecting (yes/no)?
###这是因为Git使用SSH连接,而SSH连接在第一次验证GitHub服务器的Key时,需要你确认GitHub的Key