服务器项目推送到远程仓库完成协同开发
第一步:查看当前服务器是否初始化用户和邮件
git config user.name
git config user.email
如果为空则初始化用户和邮件
git config --global user.name 'alan.liu'
git config --global user.email '1019213039@qq.com'
第二步:进入到项目根目录完成本地仓库初始化
如果项目已经存在git仓库要更换仓库则需要先删除仓库再做初始化,最后提交至本地仓库
cd /www/wwwroot/wordpress.liuyuanshan.top
rm -rf .git
git init
git add .
git commit -m 'init'
第三步:创建远程仓库
这里我选择的是国内的gitee创建远程仓库,需要注意的是项目如果是公司的就要选择私有的
第四步:在服务器添加远程仓库并推送项目至远程仓库
git remote add origin git@gitee.com:liuyuanshan11/wordpress.liuyuanshan.top.git
git push -u origin master
问题与解决
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
解决办法
cd
cd ~/.ssh/
ls
ssh-keygen -t rsa -C "1019213039@qq.com"
接着一路回车即可
ls
cat id_rsa.pub
将公钥复制出来防止gitee添加公钥处即可解决
参考文档:
https://www.cnblogs.com/wmr95/p/7852832.html
https://www.cnblogs.com/desireyang/p/12052861.html