1.创建git账户并创建私有登录
adduser git
su git
cd ~
创建私钥
ssh-keygen -t rsa
chmod 700 .ssh
cd .ssh
创建公钥列表文件
touch authorized_keys
把公钥文件添加到列表中
cat id_rsa.pub >> authorized_keys
权限问题很重要
chmod 400 *
2.创建项目仓库
2.1复制项目中的 .git文件到git家目录,并初始化服务端仓库
cp -rf /yourpath/project/.git /home/git/newproject.git
cd /home/git/newproject.git
git init --bare --shared
2.2.或者直接创建空的裸库
mkdir /home/git/project.git
cd /home/git/project.git
git init --bare
3.Git客户端工作
3.1 异常
git push 出现异常:
bash: git-receive-pack: command not found
fatal: 无法读取远程仓库。
请确认您有正确的访问权限并且仓库存在。
git pull 异常:
bash: git-upload-pack: command not found
....同上
请检查**服务端**的git-receive-pack和git-upload-pack 命令是否存在。
服务端直接输入git-receive-pack 果然提示命令不存在!
解决:做个软连接到PATH环境变量目录。比如/usr/bin
ln -s /usr/local/git/bin/git-receive-pack /usr/bin/git-receive-pack
ln -s /usr/local/git/bin/git-upload-pack /usr/bin/git-upload-pack
3.2 远程库地址设置:
远程库的添加和查看
git remote add origin https://github.com/yourname/yourproject.git
git remote -v
远程库查看和修改
git remote get-url origin
git remote set-url origin https://github.com/name/project.git
useradd和adduser的区别 https://blog.csdn.net/cynthrial/article/details/84673357
SSH私钥登录 https://blog.catmes.com/archives/ssh-login.html
https://www.linuxidc.com/Linux/2012-07/66270.htm