简体   繁体   English

Git子模块不会删除

[英]Git Submodule Won't Delete

I'm having an issue adding my submodule back to my project after previously deleting it. 在将之前的子模块添加回我的项目后,我遇到了一个问题。 When I try to add the submodule everything works perfectly up until I push my changes, git complains: 当我尝试添加子模块时,一切都完美无缺,直到我推动我的更改,git抱怨:

remote: Git submodules detected, installing:
remote: No submodule mapping found in .gitmodules for path 'ng/css/lib/submodule-name' 

Keep in mind I am installing the submodule to a new location this time around. 请记住,这次我将子模块安装到新位置。 So in the above snippet, the path in error is from the previous submodule install and not the new one. 因此,在上面的代码片段中,错误的路径来自之前的子模块安装,而不是新的。 Where is git retaining this old path information? git在哪里保留这条旧路径信息?


Initial Submodule Add 初始子模块添加

I added a git submodule 我添加了一个git子模块

git submodule add [github link]

while I was in the following directory: 而我在以下目录中:

ng/css/lib

I ended up deleting the submodule as described here . 我最后删除了这里描述的子模块。 If you don't want to read that I essentially did this: 如果您不想阅读我基本上这样做:

rm .gitmodules

Removed the submodule entry in .git/config 删除了.git / config中的子模块条目

git rm --cached ng/css/lib/submodule-name

Many successful pushes later I wanted to add the submodule back into the project. 许多成功的推动后来我想将子模块添加回项目中。 I decided it would be as simple as the previous install. 我决定它将像以前的安装一样简单。

git submodule add [github link] ng/global

But it wasn't, I get that "No submodule mapping found" error and I don't know how or where git is retaining this info. 但它不是,我得到“没有发现子模块映射”错误,我不知道git如何或在哪里保留此信息。 Is there a way to permanently clean out the submodule install? 有没有办法永久清理子模块安装?

Your commands did not delete .git/modules/ng/css/lib/submodule-name 您的命令没有删除.git/modules/ng/css/lib/submodule-name

  • Do delete that subfolder first (internal to the .git repo folder), 首先删除该子文件夹( .git repo文件夹的内部),
  • Make sure your second git submodule add did not re-introduce a .gitmodules (if yes, remove it first) 确保你的第二个git submodule add没有重新引入.gitmodules (如果是的话,先删除它)
  • and then try again to add your submodule. 然后再次尝试添加子模块。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM