huggie
huggie

Reputation: 18237

Git remove submodule and add another fork back

I am forking mapbox-ios-sdk off Github. The mapbox-ios-sdk uses FMDB as a submodule. I want my own custom version of FMDB (actually just adding a sqlite3.h from another project), hence I want my own fork of the sdk.

So on my own fork I tried to remove the original FMDB submodule and added my own fork. I removeed the submodule as according to this thread. Then I added my own FMDB fork in the same directory as the original FMDB submodule by:

git submodule add https://github.com/t2wu/fmdb ./MapView/Map/FMDB

Now I run into what I can't explain. The above command doesn't work! It would download FMDB alright but I won't see sqlite3.h in ./MapView/Map/FMDB/src. (And git log --graph I do not see my own commit of sqlite3.h and I'm on master.) However if I just put it elsewhere, say

git submodule add https://github.com/t2wu/fmdb ./MapView/MapView/FMDB

or

git submodule add https://github.com/t2wu/fmdb FMDB

Then I do see sqlite3.h. What could be happening? Does it has anything to do with CocoaPod which mapbox-ios-sdk also apparently support?

Upvotes: 2

Views: 508

Answers (1)

Jeff Runningen
Jeff Runningen

Reputation: 56

Although you removed the old submodule, the metadata still remains within .git/modules/MapView/Map/FMDB.

Since git 1.7.8, git stores submodule metadata in the parent repository's .git directory, rather than a separate .git within the submodule. That's why you see the old submodule's history and working tree.

To get everything back in shape, go to the base of your parent repository and run:

git submodule sync
cd MapView/Map/FMDB
git fetch
git checkout origin/master

Upvotes: 3

Related Questions