【问题标题】:gitlab submodule foreach push to creategitlab子模块foreach推送创建
【发布时间】:2019-08-21 17:32:46
【问题描述】:

Gitlab 提供了这种方法可以将新项目直接推送到 gitlab,而无需先在 web-gui 上对其进行初始化。以下命令效果很好:

git push --set-upstream git@my.gitlab.com:username/project-name.git master

我想做同样的事情,但要遍历新项目中的所有子模块。我正在尝试使用子模块 foreach 获取以下命令:

git submodule foreach --recursive 'sudo git push --set-upstream https://my.gitlab.com/namespace/$project-name.git master'

但它会像这样失败:

Entering 'sub-repo-1'
> GitLab: The project you were looking for could not be found.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
Stopping at 'sub-repo-1'; script returned non-zero status.

在我的用例中,我有一个项目树,其中包含我想推送到 gitlab 的数百个子模块。最终,我想将其集成到 CI 工作流程中,但首先要做的是。

任何想法为什么子模块 foreach push-to-create 在 gitlab CI 上不起作用?

【问题讨论】:

    标签: git gitlab gitlab-ci git-submodules


    【解决方案1】:

    通过反复试验,我解决了自己的问题。这是一个文件名、权限和回显问题。该命令有效。请注意,子模块 foreach 公开了 $name 变量。

    git submodule foreach --recursive 'git push --set-upstream git@my.gitlab.com:root/`printf $name | sed "s/[^a-zA-Z0-9]/-/g"`.git master'
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-09-03
      • 2014-07-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-10-05
      • 2021-03-08
      相关资源
      最近更新 更多