如何跨 2 个服务器同步 Git 存储库

发布于 2024-10-04 04:00:27 字数 328 浏览 1 评论 0原文

我正在寻找一种跨 (2) 个服务器自动同步 Git 存储库的方法,以便它们可以从第三个点互换。

情况如下: 我们在所有项目中大量使用 git,并且一些存储库的大小增长得相当快。目前我们有一台中央服务器,每个人都在向这台服务器推送/拉取。然而,这一切都通过互联网连接,因此不是最快的方式。

想法: 在办公室放置另一台服务器,并将所有 git 存储库放在那里供办公室使用。该服务器需要与在线服务器同步。 充其量用户甚至不知道他们通过某种 DNS 调整使用哪一个,因此当连接到那里的网络时,在线服务器存储库的地址会解析为办公室内的地址。

有人已经在做类似的事情了吗?或者有没有更简单的方法来实现目标。

I'm looking for a way to automatically synchronize Git repositories across (2) servers so they are interchangeable from a third point.

Situation is as follows:
We heavily use git for all our projects, and some of the Repositories grow quite fast in size. Currently we have one central server and everyone is pushing/pulling to/from this one. However this all goes through the internet connection and therefore is not the fastest way.

The Idea:
Put another server in the office, and have all the git repositories there for in-office-use. This server would need to be synchronized with the one on-line.
At best the users would not even know which one they use via some dns-adjustment, so the address of the on-line server repositories resolves to the in-office-one when connected to the network there.

Is anyone already doing something similar out there? Or is there a easier way to accomplish the target.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

却一份温柔 2024-10-11 04:00:27

我会看到这样的机制可以通过 SSH 协议(意味着像这样的框架)轻松完成gitolite 在 LAN 存储库和 WAN http 存储库上均已到位,因为这样您就可以轻松扩展ssh 强制命令机制:

  • 首先检查两个存储库是否同步 如果
  • 本地存储库不如远程存储库最新,则拒绝该命令 将
  • 本地存储库与所需的远程存储库同步

使用 hooks 更复杂,需要为每种服务器端挂钩仔细设置,以便保持该同步机制始终处于启动状态。

I would see such a mechnism easily done with the SSH protocol (meaning a framework like gitolite is in place both on the LAN repo and the WAN http repo), because then you can easily extend the ssh forced command mechanism to:

  • first check if the two repo are synchrone
  • reject the command if the local repo is less up-to-date than the remote one
  • synchronize the local repo with the remote one of needed

To do so with hooks is more complicated and would need to be carefully setup for each kind of server-side hooks in order to keep that synchronization mechanism up at all time.

混吃等死 2024-10-11 04:00:27

Gitolite 具有镜像存储库的功能。您可以将办公室中的一台设置为主机,将在线一台设置为从机,并允许推送到任一一台。

Gitolite has a feature that will mirror repositories. You could set up the one in the office as the master, and the online one as the slave, and allow pushing to either one.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文