【问题标题】:How to have synchronize two git bare repositories?如何同步两个 git 裸存储库?
【发布时间】:2014-08-18 16:08:45
【问题描述】:

是否可以将 git 裸仓库克隆为新的裸仓库?例如:

  • git init --bare mainRepo.git

然后在远程服务器中:

  • git clone --bare xxx@server:/path/mainRepo.git repoReplica.git

然后使用 cron 作业将更改从 repoReplica.git 发送到 mainRepo.git,这样我就可以让 2 个团队工作,一个直接使用 mainRepo.git,第二个使用 repoReplica.git

有可能吗?以及如何?

【问题讨论】:

    标签: git cron cron-task


    【解决方案1】:

    这是可能的,但我建议您的同步过程:

    • 不使用 cron
    • 使用post-receive hook 可以将收到的内容推送到另一个仓库
    • 将同步限制在一个分支
    • 使用不同的分支

    意思:

    • repo1 会将master 推送到repo2master_fromrepo1

      git push repo2 master:master_fromrepo1
      
    • repo2 会将 master 推送到 repo1master_fromrepo2

      git push repo1 master:master_fromrepo2
      

    【讨论】:

    • 感谢@VonC,我必须阅读才能使用它。但是,你为什么建议使用不同的分支?
    • @MadMad666 确保快进推送,而不是在使用一个唯一分支从两个存储库推送时潜在的合并冲突。
    猜你喜欢
    • 2011-06-19
    • 2020-12-06
    • 2021-11-03
    • 2014-09-12
    • 1970-01-01
    • 2014-08-03
    • 1970-01-01
    • 1970-01-01
    • 2015-12-21
    相关资源
    最近更新 更多