Git index Hanging on the way to the old submodule?

I have a repository that has two submodules. Git complains when I run git submodule init or git submodule update with the following error:

fatal: submodule mapping not found in .gitmodules for path 'AppName.xcodeproj / .. Vendor / AFNetworking'

My submodules were not in the same directory, and I decided to clean the project. I had a directory called Vendor that contained some of my submodules, but I followed the directions here to remove the submodule from git. Then I again added submodules to a new directory called submodules .

One of my submodules is the AFNetworking library, which I added as a submodule in the Vendor source directory. I deleted it a while ago and re-added it as part of the cleaning process. The app seemed like everything was fine, and my git submodule worked correctly. Now when I test another 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, since Git knows where my modules are, and everything should be fine. The same applies to 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 me a while, but I noticed that the error message refers to an old Vendor directory that no longer exists.

I opened ./git/index , directing the output of cat to a text file and using a text editor. Of course, AppName.xcodeproj/../Vendor/AFNetworking/ will appear in the index. Could this be a bad gitlink? How to clean it so that I can initialize and build my repo as usual?

+6
source share
1 answer

I tried to remove the cached link from the index from the root directory containing AppName.xcodeproj before, for example:

git rm --cached / Vendor / AFNetworking

So, I recreated the folder hierarchy, and I tried to add a dummy file inside /Vendor/AFNetworking. . I also tried adding a file called "AFNetworking" inside Vendor . Adding and removing these files did not help.

I looked at this issue again and found a blog post (link) that explained the correct way to check the index. It turns out my index had a weird link to the old submodule in it:

AppName.xcodeproj/../Vendor/AFNetworking.

The solution was to remove the exact listing file from the index, for example:

git rm --cached AppName.xcodeproj /../ Vendor / AFNetworking

Then I managed to successfully run git submodule update . It seems that the index does not always match the relative paths of the unix file system, but in some cases this may be more specific. There was some information in the Pro Git book (as amended by Chapter 9, Chapter 10 on the Internet ) that led me to suspect this, but it took a blog post for me to understand exactly how to open the index.

+1
source

All Articles