设置git同时推送gitee和github远程仓库

首页 编程分享 EXPERIENCE 正文

侯法超 转载 编程分享 2021-10-03 23:07:03

简介 因为家里github经常出现无法访问的情况,同时支持国内企业,因此开始最近开始使用gitee,但还希望将项目同步推送,又不想每次都手动推2次。 进入 .git 目录下,打开 config 文件,默认文件内容如下...


因为家里github经常出现无法访问的情况,同时支持国内企业,因此开始最近开始使用gitee,但还希望将项目同步推送,又不想每次都手动推2次。

  1. 进入 .git 目录下,打开 config 文件,默认文件内容如下
[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
        ignorecase = true
        precomposeunicode = true
[remote "origin"]
        url = https://gitee.com/geekidentity/showcase.git
        fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
        remote = origin
        merge = refs/heads/master
  1. 只需在 [remote "origin"] 添加需要推送的其他git地址,例如github 或自己的 gitlab

url = https://github.com/geekidentity/showcase.git

编辑完成如下:

[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
        ignorecase = true
        precomposeunicode = true
[remote "origin"]
        url = https://gitee.com/geekidentity/showcase.git
        url = https://github.com/geekidentity/showcase.git
        fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
        remote = origin
        merge = refs/heads/master

此时再推送 git push,则会按 url 的顺序依次推送。

转载链接:https://my.oschina.net/geekidentity/blog/5272211


Tags:


本篇评论 —— 揽流光,涤眉霜,清露烈酒一口话苍茫。


    声明:参照站内规则,不文明言论将会删除,谢谢合作。


      最新评论




ABOUT ME

Blogger:袅袅牧童 | Arkin

Ido:PHP攻城狮

WeChat:nnmutong

Email:nnmutong@icloud.com

标签云