How can I specify a branch/tag when adding a Git submodule?

前端 未结 12 1458
旧巷少年郎
旧巷少年郎 2020-11-21 06:39

How does git submodule add -b work?

After adding a submodule with a specific branch, a new cloned repository (after git submodule update --init

12条回答
  •  别那么骄傲
    2020-11-21 07:06

    An example of how I use Git submodules.

    1. Create a new repository
    2. Then clone another repository as a submodule
    3. Then we have that submodule use a tag called V3.1.2
    4. And then we commit.

    And that looks a little bit like this:

    git init 
    vi README
    git add README
    git commit 
    git submodule add git://github.com/XXXXX/xxx.yyyy.git stm32_std_lib
    git status
    
    git submodule init
    git submodule update
    
    cd stm32_std_lib/
    git reset --hard V3.1.2 
    cd ..
    git commit -a
    
    git submodule status 
    

    Maybe it helps (even though I use a tag and not a branch)?

提交回复
热议问题