• 将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

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

  • 相关阅读:
    js获取数组,对象的真实长度
    http和https区别
    react调用setstate后发生了什么
    for in for of foreach及map的区别
    事件委托(事件代理)
    CSS隐藏元素的几种方法
    react一些扩展
    [软件构造]异常的捕获与自定义
    [软件构造]可能是笔记总结吧
    计算机系统大作业
  • 原文地址:https://www.cnblogs.com/shiweida/p/8794249.html
Copyright © 2020-2023  润新知