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

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

  • 相关阅读:
    navicat连接mysql报错1251解决方案
    ubuntu 安装nodejs/npm
    sync-settings(vscode)
    ubuntu远程桌面连接windows系统
    three.js中点生成矩阵方法
    threeJs中旋转位移等操作坐标系
    ubuntu查看进程端口号及运行的程序
    Ubuntu终端远程连接linux服务器
    THREE.OrbitControls参数控制
    canvas设置长宽
  • 原文地址:https://www.cnblogs.com/shiweida/p/8794249.html
Copyright © 2011-2022 走看看