我在创建子模块时遇到了这个 git 错误。我最初在命令中有一个错误的 URL,现在任何额外的运行都会显示此错误。有什么问题吗?
$ git submodule add -f https://github.com/Shougo/vimproc.vim.git .vim/bundle/vimproc
Adding existing repo at '.vim/bundle/vimproc' to the index
fatal: Not a git repository: .vim/bundle/vimproc/../../../.git/modules/.vim/bundle/vimproc
Failed to add submodule '.vim/bundle/vimproc'
最佳答案
也许子模块已添加到索引中。您应该将它们从索引中删除。
要完全删除子模块,请执行以下步骤:
1 从 .git/config
中删除这些行
[submodule ".vim/bundle/vimproc"]
url = https://github.com/Shougo/vimproc.vim.git
2 从 .gitmodules
中删除这些行
[submodule ".vim/bundle/vimproc"]
path = .vim/bundle/vimproc
url = https://github.com/Shougo/vimproc.vim.git
3 移除子模块目录
rm -rf .vim/bundle/vimproc
4 unstage 子模块
git rm --cached .vim/bundle/vimproc
5 删除.git/modules
中的子模块目录
rm -rf .git/modules/.vim/bundle/vimproc
最后,再次添加子模块。
关于git - 如何修复 git 中损坏的子模块配置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19508849/