本篇内容主要讲解“项目同步两个git仓库后如何同时传到gitee和github”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“项目同步两个git仓库后如何同时传到gitee和github”吧!
有时候我们为了保证仓库代码安全,可能将git代码传送到两个不同的git代码仓库。接下来演示下如何进行操作:
首先创立两个仓库
#假定创建好的两个仓库地址分别为: https://gitee.com/cigoos/mycode.git https://github.com/cigoos/mycode.git
先从其中一个仓库检出代码
git clone https://gitee.com/cigoos/mycode.git
删除仓库origin
git remote rm origin
关联两个远程仓库
# 关联gitee git remote add gitee https://gitee.com/cigoos/mycode.git git push gitee master # 关联github git remote add github https://github.com/cigoos/mycode.git git push github master
# 注意此时如果遇到下述问题 To https://github.com/CigoOS/cigoadmin_tp5.git ! [rejected] master -> master (fetch first) error: failed to push some refs to 'https://github.com/cigoos/mycode.git' 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 pull github master --allow-unrelated-histories
删除分支
git push origin --delete dev git branch -D dev
检出本地分支
#基于gitee/master创建本地分支gitee git checkout -b gitee/master gitee
合并分支
git merge --squash dev --allow-unrelated-histories
到此,相信大家对“项目同步两个git仓库后如何同时传到gitee和github”有了更深的了解,不妨来实际操作一番吧!这里是亿速云网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。