美文网首页
iOS模块化之git

iOS模块化之git

作者: SnoopPanda | 来源:发表于2020-07-01 16:22 被阅读0次
子模块submodule

submodule项目和父项目本质上是两个独立的git仓库,只是父项目存储了它依赖的submodule项目的版本号信息。

  • 添加子模块

    git submodule add <url> <path>
    

其中,url为子模块的路径,path为该子模块存储的目录路径。

  • 克隆含有子模块的项目
    当一个git项目包含子模块时,直接克隆下来的子模块目录里面是空的。
    要克隆子模块需要执行下面的步骤:
    1、初始化本地子模块配置文件

    git submodule init
    

2、更新项目,抓取子模块内容

git submodule update
  • 需要注意的地方
    确保每次提交的时候,子模块使用的是对应的版本
子树subtree
  • 添加子树

    git subtree add --prefix=<subtree name> --squash  <subtree name> <branch name>
    

通过subtree添加子模块,–squash可省略,其功能是只有最新的提交记录被引入,去掉后则是引入所有历史提交记录

  • 子树更新

    git subtree pull -P <subtree name>  <subtree name>  <branch name>
    
  • 子树提交

    git subtree push --prefix=<subtree name> <subtree name> <branch name>
    
不同之处

git submodule类似于引用,父仓库引用了子仓库,两者的更新是独立的;
而git subtree类似于拷贝,子树的修改可以在父仓库的未暂存区看到。

参考:https://blog.csdn.net/liusf1993/article/details/72765131

相关文章

网友评论

      本文标题:iOS模块化之git

      本文链接:https://www.haomeiwen.com/subject/omzcqktx.html