使用Git,子树合并具有子模块的外部项目的最佳方法是什么? [英] Using Git, what's the best way to subtree merge an external project that has submodules?

查看:104
本文介绍了使用Git,子树合并具有子模块的外部项目的最佳方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Git存储库来存储与我正在开发的网站相关的所有内容.该存储库包含与该站点相关的所有文件,包括文档,模型,原始分层图像等,以及我放置在www子目录中的Web根目录.

I'm using a Git repository for everything related to a website I'm developing. The repository holds all files related to the site, including documentation, mockups, original layered images, etc. as well as the web root stuff that I've put in a www subdirectory.

我正要开始集成已选择与项目的其余部分一起使用的CMS; CMS是一个开源项目,也由Git管理(如果重要的话,托管在GitHub上).显然,CMS必须位于www子目录中,但它不是唯一的东西–会有CSS文件,图像,CMS的模板等,因此,我选择使用子树合并策略将外部项目添加到我的存储库.因为我可能在某个时候想修改原始项目并回馈更改,所以我从GitHub克隆了CMS存储库,并从克隆中完成了子树合并.

I'm at the point where I want to start integrating the CMS I've chosen to use with the rest of the project; the CMS is an open source project that's also managed with Git (and hosted on GitHub, if that matters). Obviously the CMS needs to be in the www subdirectory, but it won't be the only thing in there--there'll be CSS files, images, templates for the CMS, etc., etc. Because of this, I've chosen to use the subtree merge strategy to add the external project to my repository. Because I may at some point want to modify the original project, and contribute changes back, I've cloned the CMS repository from GitHub and done the subtree merge from my clone.

问题是,外部项目(即CMS)具有要包含的子模块.确保子模块集成到主项目中的最佳方法是什么?我必须为每个子模块做一个子树合并吗?

The trouble is, the external project (i.e. for the CMS) has submodules that I want to include. What's the best way to make sure the submodules are integrated into the main project? Do I have to do a subtree merge for each submodule?

我不太想修改子模块,但是可能会有一两个.

I'm not likely to want to modify the submodules, but it's possible there'd be one or two that I would.

推荐答案

Git 子模块包含另一个项目的特定结帐,并且不会自动保持最新状态.因此,处理CMS子模块的最简单方法可能是跟踪它们来自远程分支的存储库.这样,您可以随时了解子模块来自的项目的更改.

Git submodules contain a particular checkout of another project, and aren't automatically kept current. So the easiest way to handle your CMS's submodules may be to track the repos that they came from as remote branches. That way you can stay informed about changes to the projects that the submodules came from.

使用子树合并会使将更改提交回CMS项目变得更加复杂(也许 finicky 是正确的词);如果您希望将许多更改提交回去,则可以编写脚本.

Using the subtree merge makes it more complicated (perhaps finicky is the right word) to submit changes back to the CMS project; perhaps it could be scripted if you expect to submit many changes back.

这篇关于使用Git,子树合并具有子模块的外部项目的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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