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

前端 未结 12 1270
旧巷少年郎
旧巷少年郎 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:57

    To switch branch for a submodule (assuming you already have the submodule as part of the repository):

    • cd to root of your repository containing the submodules
    • Open .gitmodules for editing
    • Add line below path = ... and url = ... that says branch = your-branch, for each submodule; save file .gitmodules.
    • then without changing directory do $ git submodule update --remote

    ...this should pull in the latest commits on the specified branch, for each submodule thus modified.

提交回复
热议问题