git同步提交代码到github和码云上

前言

github毕竟是国外的,有时候访问也不稳定,而且速度也比较慢,所有我在提交代码到github上的时候有时候会同步一份到码云,之前都是分为两步上传

  1. 先提交到github
  2. 将最新的代码复制一份到码云的文件夹,提交到码云

这种方式太笨了,如何在一个仓库里面同时提交到多个平台呢?

实战

分别克隆github和码云的项目到本地,修改一方的配置文件

项目案例
  1. Github:https://github.com/dqjdda/Aurora
  2. 码云:https://gitee.com/hgpt/Aurora
配置

修改.git文件夹内的config文件
这里写图片描述
将另一方 config文件内的[remote “origin”],复制到该文件内,并且修改origin名称,名称可以自定义。

测试

上传代码
git add .
git commit -m "update"
#提交到github
git push github master
#提交到码云
git push gitee master
更新代码
#从github拉取更新
git pull github
#从码云拉取更新
git pull gitee

猜你喜欢

转载自blog.csdn.net/zj7321/article/details/82222483