两个相同的git存储库 [英] Two identical git repositories

查看:106
本文介绍了两个相同的git存储库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们使用git作为我们项目的源代码,在一个大团队中工作。现在大约有一半的开发人员正在进行项目的现场阶段。这个阶段将涉及大量开发,即许多提交。与此同时,留下的另一半也将继续处理代码。



不幸的是,现场只会有间歇和不可靠的互联网连接。然而,现场团队能够在另一个团队之间同步(提交/推送/拉动)他们的变更是至关重要的。但同样重要的是,办公室的其他团队可以对中央git存储库进行更改。

因此,我正在寻找一种设置,可以让现场团队使用git高效工作,即使长时间停用互联网也是如此在互联网可用时能够与办公室进行同步。



有没有一种简单而又简单的方法可以做到这一点?

我的第一个想法是:带上我们的上网本充当服务器并拥有存储库的裸机。然后现场团队将其起源更改为上网本,并推向上网本。但是与主存储库的同步正在给我带来一些麻烦。在上网本上做git push可以正常工作,但是git fetch不会返回我在主repo上所做的更改。
此外,我担心如果两个回购协议中的文件都发生了变化,并且发生冲突会发生什么情况 - 我想有人需要在上网本上工作以解决冲突并在同步发生之前提交它? / p>

解决方案

您的设置应该可以正常工作,所以我不确定抓取有什么问题。但是,当从公司的中央仓库获取并解决冲突时,应该在本地完成:每当互联网连接启动时,一名开发人员可以从中央仓库中提取,合并和解决冲突。他自己的电脑,并将结果推向中央回购和现场回购。我相信一个人不应该直接在一个用作服务器的存储库上工作(如果它是一个裸仓库,它应该是,因为没有工作副本,所以你不能直接在仓库上工作)。这也使您无法在现场服务器上设置开发环境。



此外,现场开发人员不应该替换 origin 与现场存储库;相反,他们应该使用 git remote add 添加一个新的远程,然后调用它现场。然后,每当有人想做一个 pull , push fetch

We are using git for our project's source code, working in a large team. Now about half of the developers are leaving for the on-site phase of the project. This phase will involve heavy development, i.e. many commits. At the same time the other half left behind will also continue working on the code.

Unfortunately the on-site will only have intermittent and unreliable internet connection. Yet it is vital that the on-site team is able to synchronize (commit/push/pull) their changes between another. But it is also vital that changes made on the "central" git repository by the rest of the team in the office are available.

So I am looking for a setup that will allow the on-site team to work efficiently using git even if the internet is down for a prolonged period of time, but also to be able to synchronize to/from the office when internet is available.

Is there an easy and fool-proof way to do that?

My first idea: take a netbook with us to act as "server" and have a bare clone of the repository. Then have the on-site team change their origin to the netbook and push to and pull from the netbook. But the synchronization to the main repository is causing me some trouble. Doing a git push on the netbook works fine, but a git fetch does not return me changes made on the main repo. Additionally, I'm worried what would happen if a file was changed on both repos and there was a conflict - I suppose somebody would need to work on the netbook to resolve the conflict and commit it before synchronization can happen?

解决方案

Your setup should work, so I'm not sure what's wrong with the fetching. However, when it comes to fetching from your company's central repo and resolving conflicts, this should be done locally: whenever the internet connection is up, one developer could fetch from the central repo, merge and resolve conflicts at his own computer, and push the results to both the central repo and the onsite repo. I believe one should never work directly on a repository that is being used as a server (and if it is a bare repository, which it should be, you can't work directly on it since there is no working copy). This also saves you from setting up the development environment on the onsite server.

Furthermore, the onsite developers shouldn't replace origin with the onsite repository; rather, they should add a new remote with git remote add, and call it e.g. onsite. Then, whenever one wants to do a pull, push or fetch, one can choose whether to use the company's central repo or the onsite repo.

这篇关于两个相同的git存储库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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