zoukankan      html  css  js  c++  java
  • git submodule

    1. $ git submodule add 远程地址 [本地Path]
    拉取某个地址作为自己的子模块
    eg:
    git submodule add git@github.com:huangulong/HGLPageScroll.git GLPageScroll
    在主仓库下会生成一个文件 .gitmodules
    同时也会初始化相应子模块,且 .git/config 有了相关配置

    2. $ git submodule init
    第一次clone有子模块的仓库时,子模块的相应目录下是空的,此时就需要做该类操作
    初始化本地文件,即在本地.git/config 文件中写入相关配置

    3. $ git submodule update
    从子模块服务器抓取最新的文件合并
    也可以合并2,3两个操作,加 --recursive 可以递归检索子模块的子模块
    $ git submodule update --init
    $ git submodule update --init --recursive

    4. $ git clone --recursive-submodules 远程地址
    clone主仓库,并检索初始化所有子模块及子模块的子模块


    注: 子模块下并不是一个真正的分支,而是一个commit id
    (只有第一次看到的分支,但分支的其实也是一个commitid的别名;tag 亦是)

    在主仓库下修改了子模块的东西,需要到相应的模块目录下取提交
    $ git push origin HEAD:<name-of-remote-branch>

    在命令注解中 中括号代表可选 尖括号代表必填

     

    5. submodule 相关的配置文件

    1 [submodule "HGLKeyPicker"]
    2     path = HGLKeyPicker
    3     url = git@github.com:huangulong/HGLKeyPicker.git
    4 [submodule "GLPageScroll"]
    5     path = GLPageScroll
    6     url = git@github.com:huangulong/HGLPageScroll.git
    .gitsubmodules
     1 [core]
     2     repositoryformatversion = 0
     3     filemode = true
     4     bare = false
     5     logallrefupdates = true
     6     ignorecase = true
     7     precomposeunicode = true
     8 [remote "origin"]
     9     url = ssh://ios@test.lexandera.com/Users/gulong/git.repository/XLSubModule.git
    10     fetch = +refs/heads/*:refs/remotes/origin/*
    11 [branch "master"]
    12     remote = origin
    13     merge = refs/heads/master
    14 [submodule "GLPageScroll"]
    15     active = true
    16     url = git@github.com:huangulong/HGLPageScroll.git
    17 [submodule "HGLKeyPicker"]
    18     active = true
    19     url = git@github.com:huangulong/HGLKeyPicker.git
    .git/config

    6. Demo 

       Github

  • 相关阅读:
    SpringMVC请求参数接收总结(一)
    不用 Spring Security 可否?试试这个小而美的安全框架
    @ConfigurationProperties 注解使用姿势,这一篇就够了
    Spring Aware 到底是什么?
    git rebase VS git merge? 更优雅的 git 合并方式值得拥有
    Spring Bean 生命周期之destroy——终极信仰
    面试还不知道BeanFactory和ApplicationContext的区别?
    Java设计模式学习记录-享元模式
    Java设计模式学习记录-外观模式
    Java设计模式学习记录-装饰模式
  • 原文地址:https://www.cnblogs.com/gulong/p/15109271.html
Copyright © 2011-2022 走看看