How does git handle cloning another repository into a subdirectory?

旧城冷巷雨未停 提交于 2019-12-06 14:05:06
VonC

It handles it as a nested repository, not as a submodule.
As you found out, to declare it as a submodule:

  • the sub-directory shouldn't already exist, meaning if you already cloned your second repo, you need to delete it first before adding it as a submodule.
  • or you can try adding it directly in the .gitmodules file (not tested)

That will allow for the creation of the special entry in the git index referencing the submodule SHA1, as shown here, and detailed in the SO question "Nested git repositories without submodules?".

The second repository is being handled as a submodule by the first repository. Since you haven't defined it as a submodule though, you can not interact with it using the git submodule command, but all other commands treat it as a submodule.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!