git:具有2个同步的推/拉存储库(或1个同步的推/拉和1个拉动) [英] git: having 2 push/pull repos in sync (or 1 push/pull and 1 pull in sync)

查看:82
本文介绍了git:具有2个同步的推/拉存储库(或1个同步的推/拉和1个拉动)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在多个地理位置分散的站点上工作.

We work on multiple geographically seperate sites.

今天,我们所有的git克隆都驻留在一个站点A上.然后,站点B的用户必须ssh进行git克隆或进行更改.这些都是裸仓库,通过推送即可进行更新.

Today I have our git clones all live on one site A. Then users from site B have to ssh over to do a git clone or to push in changes. These are bare repos where the update is through pushes.

理想情况下,出于git clone/push性能的考虑,我想限制使用ssh的次数.

Ideally, for git clone/push performance, I'd like to limit having to go over ssh.

我想在站点A和站点B上保存一份git repo X的副本...并在它们之间建立一些同步机制.或让X在两个站点上都存在,但只允许推送到A(并且在克隆时在B上正确设置该设置)

I'd like to have a copy of git repo X live on site A and site B... and have some syncing mechanism between them. OR to have X live on both sites, but only allow pushing to A (and have that setup correctly at clone time on B)

我担心站点A上某人将更改推送到站点A上的仓库的同时,站点B上某人将真正冲突的更改推送到站点B上的仓库的情况.

I'm worried about the case where someone on site A pushes changes to the repo at site A at the same time that someone on site B pushes a truely conflicting change to the repo at site B.

在git中是否内置了一些同步"解决方案,用于像这样的分布式开放存储库?

Is there some 'sync'ing solution built into git for distributed open repos like this?

还是从X建立克隆的一种方法,是将其他站点的原点/父对象设置为X?

Or a way to have a clone from X set the origin/parent to the X from the other site?

谢谢

-约翰

推荐答案

有两种方法可以做到这一点.听起来您像是最想让人们从远程站点B撤离.

There are a couple of ways to do this. It sounds like you mostly want a closer place for people to pull from at the remote site B.

由于git repos不会使用rsync之类的东西对现有文件(主要是refs/heads文件)进行很多更改,因此非常适合制作repos的备份/副本.这样,您可以拥有一个站点B仓库,人们可以从站点B取回/拉出该站点.

Since git repos don't make many changes to existing files (mostly just the refs/heads files) using something like rsync works just great for making backup/duplicate copies of repos. In this way, you could have a site B repo that people can fetch/pull from at site B.

这并不能完全解决您担心的两个站点都分支到同一分支的问题(此问题是非破坏性的;在最坏的情况下,有人必须创建合并提交并将其推送到两个存储库中以协调补丁集.

This doesn't quite address the both-sites-push-to-the-same-branch issue you're worried about (this issue is non-destructive; in the worst case, someone would have to create a merge commit and push it to both repos to reconcile the sets of patches).

要解决此问题,可以将站点A设置为主仓库,将站点B设置为只读从属服务器.您可以在.git/config中指定一个选项,该选项在git-fetch联机帮助页中进行了描述:pushInsteadOf.假设您的网址是"ssh://siteB"和"ssh://siteA".支持此功能的配置如下所示:

To fix that you could make site A the primary repo and site B a read-only slave. There's an option you can specify in your .git/config that is described in the git-fetch manpage: pushInsteadOf. Say your urls are "ssh://siteB" and "ssh://siteA". A configuration to support this would be something like this:


[url "ssh://siteB"]
   pushInsteadOf = ssh://siteA

这篇关于git:具有2个同步的推/拉存储库(或1个同步的推/拉和1个拉动)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆