I have a repository which has two submodules. Git is complaining when I run git submodule init
or git submodule update
, with the following error:
fatal: no submodule mapping found in .gitmodules for path 'AppName.xcodeproj/..Vendor/AFNetworking'
My submodules were not all in the same directory, and I decided to clean up the project. I used to have a directory called Vendor
which contained some of my submodules but I followed the directions here to remove the submodule from git. Then, I re-added the submodules in a new directory called submodules
.
One of my submodules is the AFNetworking
library, which I had added as a submodule in the initial Vendor directory. I removed it a while ago and re-added it as part of the clean up process. The app seemed to build just fine, and my git submodule
commands were working correctly. Now, when I check out on a different machine, it fails as described above.
My .gitmodules
file looks like this:
[submodule "submodules/AFNetworking"]
path = submodules/AFNetworking
url = https://github.com/AFNetworking/AFNetworking.git
[submodule "submodules/LNPopupController"]
path = submodules/LNPopupController
url = https://github.com/MosheBerman/LNPopupController.git
This seems normal, as git knows where my modules are, and all should be well. The same is true of my .git/config
file:
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
precomposeunicode = true
[remote "origin"]
url = git@github.com:MosheBerman/theshmuz.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
[submodule "submodules/AFNetworking"]
url = https://github.com/AFNetworking/AFNetworking.git
The error is subtle, and it took a while for me to realize it, but I noticed that the error message references the old Vendor
directory, which no longer exists.
I opened ./git/index
by directing the output of cat into a text file and using a text editor. Sure enough, AppName.xcodeproj/../Vendor/AFNetworking/
appears in the index. Could this be a bad gitlink? How do I clean this up so I can initialize and build my repo as normal?