简体   繁体   English

git include嵌套子目录

[英]git include nested sub-directory

parentfolder(git)
    |
    |---->project1(git)
    |
    |
    |
    |---->project2(git)
    |           |
    |           |---->code
    |
    |
    |
    |
    |---->project3(git)
                |
        code<---|
                |--->images

I am working on more than one projects and all my projects have different repo, i have read many articles about nested git. 我正在从事多个项目,并且我所有的项目都有不同的仓库,我已经阅读了很多有关嵌套git的文章

But my question is that,there is any one command so that i can directly commit my parent folder and get all the changes of sub-folder(git) directly 但是我的问题是,有任何一条命令,这样我就可以直接提交我的父文件夹并直接获取子文件夹(git)的所有更改。

Assuming that all your nested repositories are git subtrees, then you can write a bash script that pulls new changes from each repository and adds the respective sub-directory to the parent staging area. 假设所有嵌套存储库都是git子树,那么您可以编写一个bash脚本,该脚本从每个存储库中提取新更改并将相应的子目录添加到父暂存区。 Then you can use that script as a pre-commit hook for parent. 然后,您可以将该脚本用作父级的预提交钩子。

As an aside, I see all too often submodules and subtrees being used simply as dependencies. 顺便说一句,我经常看到子模块和子树经常被简单地用作依赖项。 If you aren't actively developing in the submodules within the parent project and backporting commits, then you should instead consider using a dependency package manager such as composer or npm. 如果您没有在父项目的子模块中积极开发和回溯提交,那么您应该考虑使用依赖包管理器,例如composer或npm。

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

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