Git workflow for 2 separate projects sharing similar code

31 views Asked by At

I have 2 projects which each need a similar functionality ( a custom WordPress plugin ). The 2 will be substantially different in implementation but fundamentally the same thing underneath the hood.

I will be working on both of these projects concurrently, ( and just on my own not as part of a team ).

I don't know git well enough to know but is there any workflow that I could use here so that I don't have to develop the projects separately, or maybe I should be developing them separately, I don't know.

The way I imagine it would be that I would fork the first project and have 2 separate repos, which is fine but then I want to be able to bring in certain changes from project #1 into project #2 later ( after more code has been added after the fork ) ... and similarly I might want to to have the same thing going on the other direction ( from P2 to P1 ) .... can anyone help me make sense of what I should be aiming to do here.

1

There are 1 answers

0
Kache On

It depends on how exactly the two projects are isolated/co-implemented, but you can look into git submodules.

It adds the complexity of managing a third branch/repository, but it architecturally enforces the hard division between what is and isn't shared between the two projects by having both include a third shared git submodule.