views:

580

answers:

2

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.

+1  A: 

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.

Paul
Thanks, it seems like subtree merge is the way to go; I'm merging from a cloned version of the repository, so any changes to the original project would be made there, making it easy to contribute back.But how do I handle the submodules of the CMS' repo? Do I have to recursively merge each sub?
Calrion
You're right then, subtree merge is the way to go. You will have to subtree merge each of the submodules. You could bring the submodules into the clone before you merge it into your project, but that would make more work when updating in the future. Bite the bullet and do subtree merge for each sub.
Paul
Sounds good, thanks. But I just discovered a problem... the tags have (of course) been imported from the CMS repository. I WILL have conflicts. So the current thinking is just to import files and disregard the CMS history.
Calrion
If you don't need the history, then just adding the current version of the files from the submodules is by far the easiest method. If you do need the history, you'll make future updates as difficult as getting this set up.
Paul
Hmmm... somehow I think it's more important to my workflow for things to be easy than to have the entire history of updates to the CMS I'm using in my main repository. Think I'll just import the files. :)Thanks for your help, Paul!
Calrion
+2  A: 

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.

apenwarr