git submodule foreach checkout supermodule branch

前端 未结 1 981
清歌不尽
清歌不尽 2020-12-06 22:31

Consider a git repository Foo/, which has submodules bar1/ and bar2/.

Each of these has the same branches: 1 & 2.

I enter the supermodule, and I want to

相关标签:
1条回答
  • 2020-12-06 22:49

    A submodule is always by default in detached HEAD mode.

    You can make each submodule follow a branch.
    See "How to make an existing submodule track a branch".

    cd /path/to/your/parent/repo/Foo
    git config -f .gitmodules submodule.bar1.branch branch1
    git config -f .gitmodules submodule.bar2.branch branch2
    

    Then all you need to do is:

    git submodule update --remote
    

    That will update each submodule to the latest of their respective upstream branch (fetch + checkout).

    0 讨论(0)
提交回复
热议问题