git - 如何删除子模块的远程分支 (Git)

标签 git git-branch git-submodules

在名为 Repo 的 Git 存储库中,有 4 个子模块:

git config --file .gitmodules --name-only --get-regexp path

submodule.A/lib1
submodule.A/lib2 
submodule.lib3 
submodule.lib4

假设在不再需要的 lib1 子模块上有一个名为 Prototype远程分支:

git submodule foreach 'git branch -a | grep -i prototype || true'

Entering 'path-to-lib1/lib1'
  remotes/origin/FeatureA
  remotes/origin/Prototype
Entering 'path-to-lib2/lib2'
  remotes/origin/FeatureB
Entering 'path-to-lib3/lib3'
Entering 'path-to-lib4/lib4'
  remotes/origin/FeatureC

如何从 lib1 子模块中删除这个 Prototype 远程分支?

我尝试了以下方法:

git push origin --delete Prototype

git push origin --delete origin/Prototype

git push origin --delete remotes/origin/Prototype

以上 3 个命令都给出了错误:

error: unable to delete 'Prototype': remote ref does not exist 
error: failed to push some refs to 'repo-path'

(我正在尝试了解子模块的主题,但我偶然发现了这个问题,在进行一些在线搜索后我无法找到答案。)

任何带有解释的命令/建议将不胜感激。

最佳答案

将目录更改为子模块,然后 git push --delete origin Prototype

关于git - 如何删除子模块的远程分支 (Git),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52446745/

相关文章:

git rebase 停止在 git for windows 中工作

git - 推送到裸工作目录后,如何在工作树中初始化/更新 git 子模块?

git - git 提交消息的 vim 语法突出显示 - 自定义 commentchar

ruby-on-rails - 在 Rails 中切换分支时,我应该如何处理数据库架构更改?

git - 如何 pull 所有子模块的更改

Git 子模块与依赖管理?

git - 如何从 Windows cmd 保存 git 提交消息?

git - 无法将某些引用推送到远程存储库(Gerrit 禁止)

git - 按日期 Git 获取 2 次提交之间的代码行差异

git - 如何丢弃 git 子模块中修改的内容?