如何跨 2 个服务器同步 Git 存储库
我正在寻找一种跨 (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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我会看到这样的机制可以通过 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:
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.
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.