您的位置:  首页 > 技术杂谈 > 正文

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

2021-09-30 16:00 https://my.oschina.net/geekidentity/blog/5272211 侯法超 次阅读 条评论

因为家里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 的顺序依次推送。

  • 0
    感动
  • 0
    路过
  • 0
    高兴
  • 0
    难过
  • 0
    搞笑
  • 0
    无聊
  • 0
    愤怒
  • 0
    同情
热度排行
友情链接