Managing SCM and dependencies in multiple related but distinct projects with Git
I've just started using Git and I love it, but I have had an issue figuring out the best way to handle configuration control of multiple projects. So, lets say I have the开发者_如何学C following projects:
- Common
- Project1
- Project1b
- Project2
Where Project[x] has dependencies within Common and Project1b has dependencies in both Common and Project1. Right now they're all separate git repositories (which I'd like to keep) but I run into issues when I'm jumping from different branches (say in Project1) where I will subsequently have to make sure the correct branch in Common is being used. I am wondering if there's an intuitive way built into git to manage an overall system configuration (branch X from Project1 should be used with branch Y from Common).
I'm running on Windows with git extentions so (sadly) my scripting capability is limited.
Any suggestions welcomed! Thanks.
git submodules should be the right way to manage such a configuration here.
You can read more about the way to use submodules in this SO answer.
You can define a parent repo which would reference:
- Project1 with revision from a certain branch
- Common with a revision from another branch
Each time you are making changes to one of those reposities (here "submodules" of a "global" parent Git repository), you go up one level, and commit in the parent repo, in order to record the exact configuration of your submodules.
That is the way to record that "(branch X from Project1 should be used with branch Y from Common".
精彩评论