我呼吁的时候
git submodule update --init --recursive --depth 50 --remote --jobs 1
字符串
对于一个分支名为main
的子模块,当我从本地git bash调用它时,它可以正常工作,而当从GitHub CI/CD管道调用时,它会失败:
13:27:13.378819 git.c:455 trace: built-in: git rev-parse --verify origin/main
fatal: Needed a single revision
13:27:13.381233 git.c:742 trace: exec: git-sh-i18n--envsubst --variables 'Unable to find current ${remote_name}/${branch} revision in submodule path '\''$sm_path'\'''
13:27:13.381277 run-command.c:668 trace: run_command: git-sh-i18n--envsubst --variables 'Unable to find current ${remote_name}/${branch} revision in submodule path '\''$sm_path'\'''
13:27:13.384468 git.c:742 trace: exec: git-sh-i18n--envsubst 'Unable to find current ${remote_name}/${branch} revision in submodule path '\''$sm_path'\'''
13:27:13.384504 run-command.c:668 trace: run_command: git-sh-i18n--envsubst 'Unable to find current ${remote_name}/${branch} revision in submodule path '\''$sm_path'\'''
fatal: Unable to find current origin/main revision in submodule path 'roles/trendmicro-ds-agent-branch'
型
这是我的.gitmodules文件:
[submodule "roles/trendmicro-ds-agent-branch"]
path = roles/trendmicro-ds-agent-branch
url = ../../modules/ansible/trendmicro-ds-agent
branch = main
型
当我在. gitmdoules中将branch = main
替换为branch = master
(其中master是子模块项目中的主分支)时,它在管道中也能正常工作。
你知道出什么事了吗?
1条答案
按热度按时间irtuqstp1#
在检出整个工作副本时,确保
--single-branch
选项未被设置。Git也会将这个设置应用到你的子模块中。它只会 checkout 默认的分支(在你的例子中是
master
)。稍后,当你运行git submodule update
切换到配置的branch = main
时,它无法在本地找到它并失败。GitHub操作
正如你提到的GitHub CI/CD。如果你使用
actions/checkout
action,运行fetch-depth: 0
就足以确保它获取 * 所有 * 分支:字符串