创建了许多git分支的联合分支 [英] creating a union branch of a number of git branches

查看:165
本文介绍了创建了许多git分支的联合分支的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够在其他分支上分层,并让这些分支独立修订。例如,这可以用来将各个子项目的二进制文件统一到同一个 bin 目录中。一般来说,一个给定的文件只会出现在一层中。



理想情况下,我想我会用unionfs来完成这个任务,但它必须以某种方式提供访问各种.git目录,这些目录将出现在同一根目录的所有子目录中。无论如何,我认为工会实际上不工作?所以看起来像是一个更好的主意,只是维护从回购根源到包含图层的其他存储库的一系列符号链接。



我正在考虑做类似这:


  • 将每个图层保存在一个单独的存储库中

  • 在主图层中维护符号链接repo到应该分层的每个文件中

  • 将符号链接添加到主.gitignore,以便在切换分支时不会被删除。

  • 与Windows完全不兼容,以便能够编辑它们在根存储库中位置的文件。 IE使用符号链接,而不是将文件复制到master repo中。



跟踪每个源代码的ID层,因此,例如,在后续修订中从图层中移除的文件可以将其符号链接从源回购库中移除并从主回购库的.gitignore文件中移除。



<看起来这样的系统最终会像 git submodule 一样工作,主要区别在于子模块将共同驻留在存储库的相同根级别。 / p>

我想知道是否已经有一个实用程序来管理它?我研究使用 stg (堆叠的git)来实现这种结构,但它似乎不是它的一杯茶。

解决方案

如果想法是有两个或多个分支处理单独的更改,但有一个分支将它们包括在一起进行测试,则可能需要查看GIT post-commit / post-update hook将各分支自动合并到混合分支中。



如果不是用于测试,那么我想考虑重构事情是成立的,可能会把事情分解成子模块。


I'd like to be able to layer other branches on top of an existing branch, and have those branches be revisioned independently. This would be useful, for example, to allow the binaries for various subprojects to be unified into the same bin directory. In general a given file would only be present in one layer.

Ideally I guess I would use a unionfs to accomplish this, but it would have to somehow provide a way to access the various .git directories, which are to appearances all subdirectories of the same root. Anyway I think unionfs doesn't actually work? So it seems like a better idea to just maintain a set of symbolic links from the root of the repo to other repositories containg the layers.

I'm considering doing something like this:

  • keep each 'layer' in a separate repository
  • maintain symbolic links within the master repo to each file which should be layered
  • add the symbolic links to the master .gitignore so that they will not be removed when switching branches.
  • be completely incompatible with Windows, in order to make it possible to edit files in their location in the root repository. IE use symbolic links instead of just copying the files into the master repo.

It would make sense to track the source commit ID of each layer, so that, for example, files removed from the layer in a subsequent revision can have their symlinks removed from the source repo and be removed from the master repo's .gitignore file.

It seems like such a system would end up working a bit like git submodule, with the key difference that submodules would co-inhabit the same root level of the repository.

I am wondering if there is already a utility to manage this? I looked into using stg (stacked git) to implement this sort of structure, but it doesn't seem to be its cup of tea.

解决方案

If the idea is to have two or more branches that deal with separate changes but have one branch that includes them together for testing, you might want to look into a GIT post-commit/post-update hook to auto merge the various branches into the blended branch.

If it's not for testing, then I would want to think about restructuring how things are set up, possibly breaking things into submodules instead.

这篇关于创建了许多git分支的联合分支的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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