Reputation: 106
I use git version controll and I have multiple projects that uses same base directory, although some changes are made project specific.
Is there a way I could track with same git repo the superfolder (root/private/core in my case) and both public and private project specific directories aswell. Also, if I make changes in one project to core files, I would like that changes are made in other projects git repo aswell.
The way i have came up is to make a git repo in the root folder and then make branches for project, and not track other project files. But with this method I have to merge core changees in other projects and there is kind of a logic error aswell, because in this case branch would be used as project.
I have looked into submodules aswell, but that seems not to be the best solution aswell. If there is a solution that requires me to change my project directory system I am able to do it, although i would like to keep public, private and core directorys separately.
Simplified example of my directory at the moment:
In private project folder there are core php extensions that are project specific and in public project folder is only stylesheets, javascript and index.
Upvotes: 2
Views: 304
Reputation: 97282
Instead of submodules (which have own limitation - "you cannot modify the contents of the submodule from within the main project" - and will change your usual Git-workflow) you can think about git-subtree, in which case core will be added as subtree (but still exist as separate repo) in all superprojects. Use-case of git-subtree in a situation reminiscent of your state
Upvotes: 1
Reputation: 1324847
I have looked into submodules aswell, but that seems not to be the best solution as well
Yet it could be a valid solution with:
private
a parent repo, including core
, project1
and project2
as submodulespublic
a parent repo, including project1
and project2
as submodulesEach time you modify a submodule (like project1
in private
), you need to:
private
), public
/ project1
)Not exactly trivial, but that allows you to keep an exact reference to the configuration used by each parent repo ("configuration" being the exact list of SHA1 of the submodules you need)
Upvotes: 0