服务端
1.下载git
yum -y install git
2.创建仓库
cd /usr/local mkdir git cd git git init --bare hello.git
3.创建git用户并赋予hello仓库权限
useradd git useradd git chown -R git:git hello.git
4.禁用git登录权限
vi /ect/passwd git:x:500:500::/home//git:/user/bin/git-shell
客户端
1.创建用户
git config --global user.name "你的名字" git config --global user.email "你的邮箱"
2.创建密钥
ssh-keygen -t rsa -C "你的邮箱"
3.将公钥添加至服务器
将C:\Users\Administrator\.ssh\id_rsa.pub内容拷贝到/root/.ssh/authorized_keys
如果仍然提示密码则在/home下创建.ssh目录,创建authorized_keys文件
4.克隆远程仓库
git clone [email protected]:/usr/local/git/hello.git
5.创建test.txt文件并提交
echo 'hello world'>test.txt git add test.txt git commit -m'测试' git push