简体   繁体   English

使用Git管理多个相关但不同的项目中的SCM和依赖项

[英]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. 我刚刚开始使用Git,但我很喜欢它,但是在确定处理多个项目的配置控制的最佳方法时遇到了一个问题。 So, lets say I have the following projects: 因此,可以说我有以下项目:

  • Common 共同
  • Project1 项目1
  • Project1b 项目1b
  • Project2 项目2

Where Project[x] has dependencies within Common and Project1b has dependencies in both Common and Project1. 其中Project [x]在Common中具有依赖项,而Project1b在Common和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. 现在它们都是单独的git存储库(我想保留),但是当我从不同的分支(例如Project1)中跳转时遇到问题,随后我将不得不确保在Common中正确的分支是正在使用。 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). 我想知道git中是否内置了一种直观的方法来管理整个系统配置(Project1中的分支X应该与Common中的分支Y一起使用)。

I'm running on Windows with git extentions so (sadly) my scripting capability is limited. 我在Windows上使用git扩展运行,因此(可悲的是)我的脚本功能受到限制。

Any suggestions welcomed! 欢迎任何建议! Thanks. 谢谢。

git submodules should be the right way to manage such a configuration here. git子模块应该是此处管理此类配置的正确方法。

You can read more about the way to use submodules in this SO answer . 您可以在此SO答案中了解更多有关使用子模块的方式的信息。

You can define a parent repo which would reference: 您可以定义一个父仓库,该仓库将引用:

  • Project1 with revision from a certain branch 某个分支的修订版Project1
  • 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. 每次您对其中一个存储库(这里是“全局”父Git存储库的“子模块”)进行更改时,您都要上一层并提交父存储库,以便记录子模块的确切配置。

That is the way to record that "(branch X from Project1 should be used with branch Y from Common". 这就是记录“((Project1的分支X应该与Common的分支Y一起使用”的记录方式)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM