Question

How two organize two projects that have common part of code ?

I have 2 projects that have common part of code, that is being changed from time to time. I use TortoiseGit.

For example

project 1 - master
project 2 - dev-branch. 

As I understand when I make changes in dev-branch (changes in specific dev-branch code and in common with master code) and then merge master with dev-branch, master will get also specific dev-branch code.

How do I resolve this situation to get, for master, only master specific changes?

Was it helpful?

Solution

  1. You have to have an additional repository for the code you have in common. So in your case in total you'll have super-project1, super-project2, and a new sub-project repository.
  2. For any of the files you want to be in the shared project, you must collect them into a special special sub directory (or tree) such that none of the super-project files are contained in the shared code directories.
  3. After strict separation you can use Git's submodules or git-subtree (Use Case of subtree, identical to yours)

OTHER TIPS

You can even have a git repo inside of a git repo, but you will end up 2 histories. I chose this option myself because I always change my inside git repo as a block since I want to update its unit tests whenever I update that repo.

you could use submodules for this

--edit correcting link

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top