How to Organize a Framework-Based Project in Git

git

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?

Best Answer

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>
Related Topic