处理 git 子模块

huangapple go评论45阅读模式
英文:

Handling git submodules

问题

在这个帖子https://stackoverflow.com/questions/56799562/git-submodule-add-error-does-not-have-a-commit-checked-out/75305137?noredirect=1#comment132992857_75305137中,我和楼主有着完全相同的经历,所以我阅读了回答,看是否有解决方法。有几位回答者表示解决方法是删除已添加子模块中的.git文件。在那个帖子中,我提出了一个问题:"但这不是是否会破坏子模块的目的,将其转变为一个本地仓库,而没有任何与子模块原始来源的连接?"(请参见https://stackoverflow.com/a/75305137/13000598)

所以,我想问一下。在原始帖子中描述的情况下,处理的正确方法是删除.git子目录吗?如果是的话,那么这不是会破坏git submodule add的目的吗?

我是否错误地认为这会破坏git submodule add的目的?

英文:

In this thread https://stackoverflow.com/questions/56799562/git-submodule-add-error-does-not-have-a-commit-checked-out/75305137?noredirect=1#comment132992857_75305137

I had the exact same experience as the OP, so I read the responses to see if there was a solution. Several people answered that the solution was to delete the .git file in the added submodule. In that thread I asked "But doesn't that defeat the purpose of the submodule and just turn that tree into a local repository without any connection back to where the submodule came from?" (See https://stackoverflow.com/a/75305137/13000598)

So, I'm asking. Is the proper method to handle the situation described by the OP in the original thread to delete the .git subdirectory and, if so, how does that not defeat the purpose of git submodule add?

Am I wrong in believing that it does defeat git submodule add's purpose?

答案1

得分: 1

根据这里的解释,"没有检出任何提交" 意味着父存储库仍然认为子文件夹仍然是一个子模块。

最好在尝试将其再次添加为子模块之前,尝试清除该子文件夹的任何痕迹

英文:

As explained here, "does not have a commit checked out" means the parent repository still think that a subfolder is still a submodule.

It is best to try and clean any trace of that subfolder, before attempting to add it again as a submodule.

huangapple
  • 本文由 发表于 2023年2月9日 02:28:38
  • 转载请务必保留本文链接:https://go.coder-hub.com/75390225.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定