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

前端 未结 12 1269
旧巷少年郎
旧巷少年郎 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 06:41

    We use Quack to pull a specific module from another Git repository. We need to pull code without the whole code base of the provided repository - we need a very specific module / file from that huge repository and should be updated every time we run update.

    So we achieved it in this way:

    Create configuration

    name: Project Name
    
    modules:
      local/path:
        repository: https://github.com//.git
        path: repo/path
        branch: dev
      other/local/path/filename.txt:
        repository: https://github.com//.git
        hexsha: 9e3e9642cfea36f4ae216d27df100134920143b9
        path: repo/path/filename.txt
    
    profiles:
      init:
        tasks: ['modules']
    

    With the above configuration, it creates one directory from the provided GitHub repository as specified in first module configuration, and the other one is to pull and create a file from the given repository.

    Other developers just need to run

    $ quack
    

    And it pulls the code from the above configurations.

提交回复
热议问题