zoukankan      html  css  js  c++  java
  • 将Git工程提交到两个不同的仓库

    使用场景:

    • 备份代码
    • 在使用新的代码管理仓库的过渡过程中,我们并不想直接扔掉原有代码管理仓库,同时又不想维护两套代码(我遇到的场景是从github迁移到GitLab过程中)

    有两种配置方式,直接看配置文件

    1. 修改项目.git文件下的config文件(提交到两个仓库的相同分支)
     1 [core]
     2     repositoryformatversion = 0
     3     filemode = false
     4     bare = false
     5     logallrefupdates = true
     6     symlinks = false
     7     ignorecase = true
     8     hideDotFiles = dotGitOnly
     9 [remote "origin"]
    10     url = ssh://github仓库地址
    11     url = http://gitlab仓库地址
    12     fetch = +refs/heads/*:refs/remotes/origin/*
    13 [branch "master"]
    14     remote = origin
    15     merge = refs/heads/master

      

      2.修改项目.git文件下的config文件(提交到两个仓库的不同分支)

     1 [core]
     2     repositoryformatversion = 0
     3     filemode = false
     4     bare = false
     5     logallrefupdates = true
     6     symlinks = false
     7     ignorecase = true
     8     hideDotFiles = dotGitOnly
     9 [remote "origin"]
    10     url = ssh://github仓库地址
    11     fetch = +refs/heads/*:refs/remotes/origin/*
    12 [remote "mirror"]
    13   url = http://gitlab仓库地址
    14   fetch = +refs/heads/*:refs/remotes/origin/*
    15 [branch "master"]
    16     remote = origin
    17     remote = mirror
    18     merge = refs/heads/master

    用这种方法需要推送2次
    git push origin
    git push mirror

    在没有特别要求时第一种配置方式更简洁。前提是在备份仓库建立同名的分支。

  • 相关阅读:
    关于Tortoise git汉化包装了,不管用,仍然是英文菜单的问题记录
    《EM-PLANT仿真技术教程》读书笔记
    使用java8的lambda将list转为map(转)
    mybatis动态sql中的trim标签的使用(转)
    python变量与常量内容:
    变量与常量
    计算机与操作系统小结
    编程与计算机基础
    元类
    爬虫百度图片
  • 原文地址:https://www.cnblogs.com/shiweida/p/8794249.html
Copyright © 2011-2022 走看看