如何在GitAction中获取子模块最新代码

Alternatives

  • You can use the submodules input to the checkout action:
    1
    2
    3
    4
    5
    steps:
    - name: Checkout repository and submodules
    uses: actions/checkout@v3
    with:
    submodules: recursive
  • another way, you can just run the command directly:
    1
    2
    3
    4
    5
    steps:
    - name: Checkout repository
    uses: actions/checkout@v3
    - name: Checkout submodules
    run: git submodule update --init --recursive
  • or use git command with git-action plugin instead:
    1
    2
    3
    4
    5
    6
    7
    steps:
    - name: Checkout repository
    uses: actions/checkout@v3
    - name: Checkout submodules
    uses: srt32/git-actions@v0.0.3
    with:
    args: git submodule update --init --recursive

Git submodule 切换分支的代码

  • 切换分支语法
1
git config -f .gitmodules submodule.xxx.branch xxx1
  • 示例
1
git config -f .gitmodules submodule.themes/anzhiyu.branch dev

xxx替换成对应的子模块名称(可在.gitmodules文件中查看到),xxx1替换成子模块需要的目标分支

原文链接:https://github.com/marketplace/actions/checkout-submodules