首页 > 解决方案 > 即使我正在使用子模块,也会警告嵌入 Git 存储库

问题描述

我试图弄清楚 Git 子模块是如何工作的。我在线阅读了很多文档并设法将子模块添加到我的项目中。这似乎可行,但由于某种原因,我在终端中不断收到此警告:

warning: adding embedded git repository: web/modules/custom/svds_adminmenu
hint: You've added another git repository inside your current repository.
hint: Clones of the outer repository will not contain the contents of
hint: the embedded repository and will not know how to obtain it.
hint: If you meant to add a submodule, use:
hint: 
hint:   git submodule add <url> web/modules/custom/svds_adminmenu
hint: 
hint: If you added this path by mistake, you can remove it from the
hint: index with:
hint: 
hint:   git rm --cached web/modules/custom/svds_adminmenu
hint: 
hint: See "git help submodule" for more information.

我觉得这很奇怪,因为 svds_adminmenu 存储库是我作为子模块添加的存储库。那么为什么它仍然给我这个警告。

我所做的如下:

git clone path/repo.git 

在此之后,我使用了以下内容

git submodules update --init

当我对 .gitignore 文件进行更改并执行以下操作时,我在终端中收到此警告:

git rm -r --cached
git add --all
git commit -m '.gitignore changed'

出了什么问题?

标签: gitversion-controlgit-submodules

解决方案


您可以删除子文件夹中的 .git 文件夹,然后使用

git add the_child_folder
git commit -m 'commit message'

推荐阅读