【问题标题】:git submodule update --remote --merge yields fatal: Needed a single revisiongit submodule update --remote --merge 产生致命:需要单个修订
【发布时间】:2021-07-31 02:15:09
【问题描述】:

假设我有一个repo,其子模块结构如下:

[submodule "themes/sanskrit-documentation-theme-hugo"]
    path = themes/sanskrit-documentation-theme-hugo
    url = https://github.com/sanskrit-coders/sanskrit-documentation-theme-hugo.git
    update = merge
[submodule "content"]
    path = content
    url = https://github.com/vvasuki/kAvyam.git
    branch = content
    update = merge

在查看云端存储库时,我希望将所有子模块更新为来自各自远程分支的最新提交。

在 github 操作中,如果我运行(例如 hereworkflow filegit submodule update --remote --merge,我会收到此错误 fatal: Needed a single revision。是什么赋予了?有其他选择吗?

尝试了替代方案

git submodule foreach "(git checkout $(git config -f $toplevel/.gitmodules submodule.$name.branch || echo master); git pull)&" - 这适用于我的计算机,但不适用于 github 操作(主分支是 wrongly checked out 用于子模块内容)。

【问题讨论】:

  • 您不能与--depth 1 合并(无论如何;一些非常具体、相对谨慎的情况可能会起作用)。在子模块中使用更深的或完整的克隆。

标签: git git-submodules github-actions


【解决方案1】:

问题似乎与操作/结帐步骤有关。以下工作:

在下面的操作中禁用子模块初始化

    - name: Checkout
      uses: actions/checkout@master
      with:
        submodules: false

手动更新:

    - name: Update submodules
      if: ${{ github.event_name != 'pull_request'}}
      run: |
        set -o xtrace
        git submodule update --init --recursive
        git submodule update --remote --merge --recursive

【讨论】:

    【解决方案2】:

    您正在使用1 的深度进行克隆,然后使用--depth 1 运行git pull --recurse-submodules 命令。我建议将大部分工作流程替换为我个人也经常使用的类似内容。

    name: Submodule Update
    
    on:
      push:
        branches: [ main ]
        tags:
        - '*'
      schedule:
      - cron: '20 * * * *'
    
    jobs:
      submodule-update:
        runs-on: windows-latest
        steps:
        - uses: actions/checkout@main
          with:
            # we need the submodules.
            submodules: recursive
    
        - name: Update submodule.
          run: git submodule update --remote
    
        # this creates a commit with the worker's working tree changes (in this case from the submodule update command) and pushes it to a branch named "app/updated-submodules".
        - name: Create Pull Request
          id: cpr
          uses: peter-evans/create-pull-request@main
          with:
            # you will need an Personal Access Token if you want workflow runs to trigger inside of the created pull request created by this workflow.
            token: ${{ secrets.GITSYNC_TOKEN }}
            commit-message: Update submodules.
            # do not change it does not change anything other than the github-actions account basically pushes it.
            committer: GitHub <noreply@github.com>
            author: any user here <any user's noreply github email here>
            signoff: true
            branch: app/updated-submodules
            base: main
            # delete branch after merge.
            delete-branch: true
            title: 'Update submodules.'
            body: |
              Update submodules
              - Auto-generated by [create-pull-request][1]
    
              [1]: https://github.com/peter-evans/create-pull-request
            draft: false
    

    【讨论】:

    猜你喜欢
    • 2013-11-06
    • 2023-02-26
    • 2016-11-08
    • 2010-12-31
    • 2012-11-05
    • 2017-01-29
    • 2022-07-07
    • 2014-11-28
    • 2018-10-18
    相关资源
    最近更新 更多