我们使用 GIT 来管理我们的项目。
每个项目都有一个“核心”(就像我们将构建项目的框架)所以每个项目至少有 2 个远程分支:
- 该核心框架的 1 个存储库。
- 每个客户项目 1 个存储库。
我们也有模块。每个模块都有一个包含基本功能的核心,我们从这个基础上为每个客户个性化每个模块。
- 所以我们有包含在每个客户项目中的子模块
- 但我不知道如何处理子模块的个性化部分。
如果我想在必须仅在 1 个特定客户端项目中使用的子模块中添加一些新文件,GIT 如何帮助我?
由于这些文件针对主项目进行了个性化设置,因此最好的情况是在客户端项目分支中提交子模块中包含的一些文件,但看起来我不能,因为每个子模块都是独立的。
Ps.: 我们使用SmartGit。
最佳答案
这是一个可以使用 git-subtree( merge )的场景
If you made changes to the other project in your repository, they may want to merge from your project. This is possible using subtree — it can shift up the paths in your tree and then they can merge only the relevant parts of your tree.
http://www.kernel.org/pub/software/scm/git/docs/howto/using-merge-subtree.html
The idea of the subtree merge is that you have two projects, and one of the projects maps to a subdirectory of the other one and vice versa. When you specify a subtree merge, Git is smart enough to figure out that one is a subtree of the other and merge appropriately — it’s pretty amazing.
http://progit.org/book/ch6-7.html
但我想你想使用子模块而不是离开它。
关于Git子模块管理策略,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5805251/