如何解决git submodule update --remote --merge 产生致命错误:需要一个修订版
假设我有一个具有以下子模块结构的 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 操作中,如果我运行(例如 here 和 workflow file )git 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 用于子模块内容)。
解决方法
问题似乎出在操作/结帐步骤上。以下工作:
在下面的动作中禁用子模块初始化
- 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
,
您正在以 1
的深度进行克隆,然后使用 git pull --recurse-submodules
运行 --depth 1
命令。我建议将大部分工作流程替换为我个人也经常使用的类似内容。
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
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。