linux搭建git服务器
// 下载
yum install -y git
// 创建git账号 分组
groupadd git
useradd gittest
// 创建仓库文件夹
mkdir -p /opt/git/test.git
// 创建仓库
cd /opt/git/test.git
git init --bare
// 设置权限
chown -R git:git /opt/git/test.git
// 设置git账户密码
passwd git
服务器搭建完成了。客户端clone(格式为<git账号>@<地址>:<仓库文件夹地址>):
git clone git@yourhost:/opt/git/test.git
第一次clone会提示,直接一路回车,如果提示要输入密码,就输入上面设置的git账号密码。
clone下来,新建一个文件index.txt,客户端打开git bash,提交:
git add index.txt
git commit -m '提交描述'
// 如果git commit遇到报错,提示需要设置邮箱和用户名,则用下面2条命令设置:都可以随便填写
git config --global user.email "your email"
git config --global user.name "your name"
// 提交远程分支
git push origin master