代码同时上传到github和码云

目前git的大平台有国内的gitee,国外的github

那么如何在本地仓库同时上传到这两个平台呢?

首先要在项目目录下右键选择Git Bash Here:

如果没有Git Bash Here的话安装地址:https://tortoisegit.org/download/

下面是具体操作:

//删除 已关联的名为origin的远程库:

>git remote rm origin

//关联gitee 的远程库gitee_demo  关联git地址: https://gitee.com/xxx/demo.git

>git remote add gitee_demo https://gitee.com/xxx/demo.git

//关联github 的远程库github_demo  关联git地址: https://github.com/xxx/demo.git

>git remote add github_demo  https://github.com/xxx/demo.git

//查看本地库连接的远程看

>git remote -v

会显示:

gitee_demo [email protected]:xxx/demo.git(fetch)

gitee_demo [email protected]:xxx/demo.git(push)

github_demo [email protected]:xxx/demo.git(fetch)

github_demo [email protected]:xxx/demo.git(push)

//推送命令

//推送github:

>git push github_demo  master

//推送gitee:

>git push gitee_demo master

如果在sourcetree中右键master->推送到,  就会发现有github_demo以及gitee_demo的选项

然后选择某个远程库就会上传到相应的库中,当然上传的过程中如果没设置过账号密码,会弹出提示框重新设置下

发布了100 篇原创文章 · 获赞 5 · 访问量 39万+

猜你喜欢

转载自blog.csdn.net/jinxinxin1314/article/details/104572140