6

Ok, so I have what appears to be a complex situation, and I'm wondering how to best organize it. I have limited experience with Git so I might be missing system.

I have a framework developed internally. This framework is being used my ProjectX, ProjectY, and ProjectZ. If I update the core components of the framework (Located in /core and /resources) I want it updated for all of my projects. However I want to be able to update the custom components of each project and have that tracked in Git as well (All custom content is located in /app).

So I'm thinking on our central server we should have a Git repository just for the core framework. This will contain the following:

core/*
resources/*
.htaccess
index.php

Then each of our projects will have their own repository on the server containing the app/ folder.

Would this work with Git locally however? Can we pull the contents of two repositories to one folder? We might have /home/brandon/projects/ProjectX.

Just looking for input on how to organize this. Also, how would we push to the live/test environments? Would SSHing into the production environment and pulling from the central repository be the way to go?

2 Answers 2

5

Sounds like git submodules are exactly what you are looking for.

Put your framework in one repo. And each separate project into its own repo as well. Then include the framework as submodule in the project-repos:

git submodule add <clone path to framework repo>
1

Including the framework can be part of the build rather than part of the repository. When you build the app, the framework files get copied into your local working copy, so that anything that depends on the framework will work. Add the framework folders to your .gitignore file so they will not be included in the project specific repo.

For framework changes, use a separate repo that includes the framework folders and a simple test app so you can see the changes as you work on them.

Ignoring the framework files in the project repo is optional, but if you include them in the project, you need to be a bit more careful about not making framework changes directly in the project.

You also have the option of using submodules, but that works best if the framework is a subfolder of the project rather than the other way around.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.