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

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

  • 相关阅读:
    计算器
    安卓第四周作业
    安卓第三次作业
    补10.21
    补:10.21
    增删改查
    android-數據庫
    安卓 -登陆界面
    android 第Ⅱ次作业
    第一个java代码
  • 原文地址:https://www.cnblogs.com/shiweida/p/8794249.html
Copyright © 2011-2022 走看看