标签:Git origin git hint 仓库 Gitee Github push 推送
文章转载:git技巧-项目同时推送至github和gitee
一次push推送代码到多个远程仓库(以第一个仓库为主,第二个仓库作为备份)
1.初始化本地仓库
git init
2.设置第一个目标远程仓库 Github
git remote add origin git@github.com:远程仓库地址
3.设置第二个目标远程仓库 Gitee
git remote set-url --add origin git@gitee.com:远程仓库地址
4.拉取第一个仓库的默认分支的代码到本地
git pull origin main
5.新建测试文件,推送到远程仓库,测试推送是否成功
touch info.txt
git add info.txt
git commit -m "update"
git push origin main
出现的问题:
推送时第一个仓库成功,第二个失败。错误代码:
error: failed to push some refs to 'gitee.com:远程仓库地址'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
解决方案:
强制推送,覆盖第二个仓库的代码
git push origin main --force
标签:Git,origin,git,hint,仓库,Gitee,Github,push,推送 来源: https://www.cnblogs.com/shiningwonders/p/16383276.html
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。