Search code examples
gittortoisegittortoisemerge

Git : how to organize two projects that have common code


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?


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)