- 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.
- 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.
- After strict separation you can use Git's submodules or git-subtree (Use Case of subtree, identical to yours)
Git : how to organize two projects that have common code
-
02-12-2021 - |
Вопрос
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?
Решение
Другие советы
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