您可以在两个GIT Repos之间同步一个单独的文件夹吗? [英] Can you sync one individual folder between two GIT Repos?

查看:163
本文介绍了您可以在两个GIT Repos之间同步一个单独的文件夹吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我在工作中使用两个开发远程GIT仓库,每个仓库都有其自己的用途,即具有自己的一组文件夹和文件等.

So I'm using two development remote GIT repos at work, each repo has its own purpose with its own set of folders and files and such.

例如,类似这样的

REPO1

Folder A
Folder B
Folder C

REPO2

Folder C
Folder D
Folder E

因此,文件夹C在两个存储库中都是相同的文件夹,包含相同的文件等.所有新开发工作都在REPO1中完成,用于文件夹C,大约每周一次,有人进入并手动合并所有最新更改从REPO1文件夹C到REPO2文件夹C.

So Folder C is the same folder in both repo's, it holds the same files etc. All new development work is done in REPO1 for folder C, and about once a week someone goes in and manually merges all the latest changes from REPO1 Folder C to REPO2 Folder C.

这意味着REPO2对于文件夹C总是有点过时.因此,对于从REPO1REPO2的每次提交,都可以仅自动同步文件夹C,而不会影响每个存储库中的任何其他文件夹,因为它们是不同的,需要保持这种方式吗?

This means that REPO2 is always a little out of date for Folder C. So is it possible to sync just Folder C automatically for every commit from REPO1 to REPO2, without affecting any other folders in each repo, as those are different and need to remain that way?

推荐答案

看起来您正在寻找的是子模块.基本上,这个想法是:

Looks like what you're looking for is submodules. Basically the idea is:

  • 使用Folder C
  • 的内容创建一个新的仓库
  • REPO1REPO2
  • 中将此新存储库作为子模块进行引用
  • 当您使用REPO1Folder C时,它实际上将更新此新存储库
  • 然后,您只需要在REPO2
  • 中更新此子模块即可.
  • Create a new repo with the content of Folder C
  • Reference this new repo as a submodule both in REPO1 and REPO2
  • When you'll work in the Folder C of the REPO1 it will actually update this new repo
  • You'll then just have to update this submoule in REPO2

您应该查看 http://git-scm.com/book/en/Git-Tools-Submodules 入门.

如果我们谈论的是代码仓库,那么一个更简单的解决方案可能是:

If we're talking about a repo of code, an easier solution could be:

  • Folder C源中创建一个库(例如,如果使用Java,则为maven包)
  • REPO2中删除Folder C.相反,请添加对此库的引用
  • 然后,当您想在REPO2
  • 中对其进行更新时,只需发布​​该库的新版本即可.
  • Create a library (eg: a maven package if you're using java) out of Folder C sources
  • Remove Folder C from REPO2. Instead, add a reference to this library
  • Then, you'd just have to publish a new version of this library when you want to update it in REPO2

不利之处在于将它放在适当位置可能并不容易(甚至不可能).但是,如果可以的话,以后会容易得多.

The downside is that it may not be easy (or even possible) to put that in place. However, if you can, it will be much easier afterwards.

这篇关于您可以在两个GIT Repos之间同步一个单独的文件夹吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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