简体   繁体   English

自动同步2个可写git存储库

[英]Automatically sync 2 writable git repositories

I am working in a small office, where we are using git with a central repository at a windows share , where we can PUSH to and PULL from. 我在一个小型办公室里工作,我们在gitWindows share中央存储库中使用git ,我们可以在其中推送和从中拉出。 To be able to work from home, travel etc, we want to have a possibility to reach a central repo from "the outside world". 为了能够在家工作,旅行等,我们希望有可能从“外部世界”到达中央仓库。 Our internet connection is very, very slow, so it is no possibility to have just one central repository "inside" or "outside". 我们的互联网连接非常非常慢,因此不可能只有一个中央存储库位于“内部”或“外部”。

My simple attempt was the following: 我的简单尝试如下:

  • Make a central repository at the internal WIN network share: git init --bare 在内部WIN网络共享中创建一个中央存储库: git init --bare
  • Make one "outside" (eg github or an external WIN share or anything else) 做一个“外部”(例如github或外部WIN共享或其他任何东西)
  • At the internal repo call git remote add EXTERNALREPO <pathToIt> 在内部git remote add EXTERNALREPO <pathToIt>调用git remote add EXTERNALREPO <pathToIt>
  • and make a batch running every x minutes/hours, saying git fetch --tags EXTERNALREPO , git push --tags EXTERNALREPO 并每隔X分钟/小时运行一次批处理,说git fetch --tags EXTERNALREPOgit push --tags EXTERNALREPO

When working "inside", clone/push/pull the internal repo, when on the road, use the external repo for that. 在“内部”工作时,克隆/推/拉内部回购,在旅途中,使用外部回购。

Question: Is this the way to go, is there a better way, or am I completely wrong? 问题: 这是要走的路,还是有更好的路,还是我完全错了?

Related: 有关:

  1. Two-way git mirror – I do not think that wee need locking as we are not so many people. 双向git镜像 –我认为不需要锁,因为我们的人数并不多。
  2. Safe master-master setup with git? 使用git安全进行master-master设置吗? (writable git mirror) (可写的git镜像)
  3. How to keep 2 git repositories in sync automatically – As far as I know, a push lasts as long as it take to run all the hooks, AND since using a windows share, the CLIENT has to run it, so it wouldn't be a solution. 如何自动保持2个git存储库同步 –据我所知,只要运行所有的钩子,推送就一直持续下去,而且由于使用Windows共享,因此CLIENT必须运行它,因此不会一个解法。

Update 1 : I now came up with a slightly adjusted configuration. 更新1 :我现在想出了稍微调整的配置。

  • INTERNAL repo on an internal Windows Share: git init --bare 内部Windows共享上的内部回购: git init --bare
  • EXTERNAL repo on an external Windows Share: git init --bare 外部Windows共享上的EXTERNAL回购: git init --bare
  • Both repos: 两个回购:

     git config receive.denyNonFastForwards 1 git config receive.denyDeletes 1 git remote add {INTERNAL|EXTERNAL} file:///... 
  • Every x seconds/minutes/hours, call git push --all {INTERNAL|EXTERNAL} and git push --tags {INTERNAL|EXTERNAL} , at first at the internal, then at the external repository . 每x秒/分钟/小时, 首先在内部,然后在外部存储库中 ,调用git push --all {INTERNAL|EXTERNAL}git push --tags {INTERNAL|EXTERNAL}

  1. "repository at a windows share" is The Bad&Ugly Idea (tm) “ Windows共享库”是The Bad&Ugly Idea(tm)
  2. Use post-* hook in INTERNAL for pushing to EXTERNAL as it happens 使用INTERNAL中的post *钩子将其推到外部
  3. Pseudo-CVCS in DVCS is ugly (everybody can bring local travel-repo to workplace and sync from it) DVCS中的伪CVCS很丑陋(每个人都可以将本地旅行回购带到工作场所并与之同步)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM