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.
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.
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 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.
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.
An easier way to do subtree merges (and the subsequent split back out again so you can submit patches upstream) is to try the experimental git subtree tool.
来源:https://stackoverflow.com/questions/645019/using-git-whats-the-best-way-to-subtree-merge-an-external-project-that-has-sub