Вопрос

Let's call 2 projects A and B. Here's the structure for each one of them :

/
|- Foo
|   |- core
|   |    |- bar.txt
|   |    |- ...
|   |- specific
|          |- ...
|- ...

The content of /Foo/core/ should be present AND in sync locally in A and B. That means that, if i edit bar.txt in project A, I should be able to get that change in project B, on the same machine, and vice versa.

I tried to create a project named "Core", and making it a submodule of A and B. Problem is, if I edit bar.txt, push it to a remote, and then push A, obviously I can't have the code on project B with a submodule update. It's not the same project.

I also tried subtree merging. Problem is, "Core" is NOT meant to be a standalone project, and I can't develop it like it is. It's just resources files and common functionning for something larger. Therefore, I would like to be able to edit my bar.txt either in A and B, test it there as part of this project specifically, and then get it somehow in the other project to test it too.

On the Git Book, on the chapter about subtree merging, it is said :

You can [...] make changes in the rack subdirectory of your master branch and then merge them into your rack_branch branch later to submit them to the maintainers or push them upstream.

But it is not explained how should I do that, nor how can I keep my 2 local folders in sync.

Это было полезно?

Решение

Submodules will work. When you make a change to the core project when working on project A, you push changes in both of those. To update core in project B, you simply need to pull the changes when in Core in project B. CD out to project B, git add -A && git commit -m "updated core" to update project B to the latest of core.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top