删除 git 子模块存储库中的分支是否会使该分支中的提交对超级项目不可用?

发布于 2024-09-08 22:16:09 字数 263 浏览 9 评论 0原文

我对 git 相当陌生,我怀疑这个问题的答案是否定的,但想在这里咨询一些更有经验的 git 用户。

我有一个超级项目,其中包含对子模块的开发分支的引用。我有点担心,当我将该开发分支重新设置为 master 并删除它时,引用的子模块提交将会消失,从而使引用它的超级项目提交无法使用。


虽然我已经回答了这个问题,但它又提出了另一个问题。这种行为可以依靠吗?我读过 git 将已删除的项目保留在 refs 中一段时间​​,然后将其删除。这是否会导致克隆首先工作,然后又失败?

I'm fairly new to git, and I suspect the answer to this is no, but wanted to check with some of the more experienced git users here.

I have a superproject which has a commit which includes a reference to a development branch of a submodule. I'm a little worried that when I rebase that development branch onto master and delete it that the referenced submodule commit will disappear, making the superproject commit that references it unusable.


Though I've answered the question, it has brought up another question. Can this behavior be counted on? I've read that git keeps deleted items around in refs for a period of time, then removes them. Could this result in the clone working at first, then failing later?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

韬韬不绝 2024-09-15 22:16:09

由于没有得到任何答案,我决定尝试一下。我创建了一个带有子模块的项目,并在子项目中使用三种不同的配置提交了对超级项目的更改:

  1. 具有引用的分支
    提交已重新基于 master
    没有任何变化和分支
    已删除。
  2. 具有引用提交的分支被重新基于 master,并将引用压缩到另一个提交中。

  3. 具有引用提交的分支
    就被简单地删除了。

在所有这些情况下,使用“git clone --recursive”克隆超级项目成功添加了具有引用提交的子模块。

Since I didn't get any answers, I decided to try it out. I made a project with a submodule and committed changes to the superproject with three different configurations in the subproject:

  1. The branch with the referenced
    commit was rebased onto master
    without any changes and the branch
    deleted.
  2. The branch with the referenced commit was rebased onto master with the referenced squashed into another commit.
  3. The
    branch with the referenced commit
    was simply deleted.

In all of these cases cloning the superproject with 'git clone --recursive' successfully added the submodule with the referenced commit.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文