3

I have a submodule in my git project, which I have made some changes to, and uploaded to my own git server to fork it. I've changed the source URL in the master git repository to the new submodule's location, and ran git submodule sync so my .git/config file is up to date. Then i pushed everything to Bitbucket, where my data is stored. However, when I clone my main git repository, it is still pulling down the data for the submodule from the old location. Any idea what might be causing this to happen and how to fix it? It's making my forked changes not come up when I clone the repository.

Jason
  • 14,517
  • 25
  • 92
  • 153

3 Answers3

1

Most likely your .gitmodules file is incorrect.

If you open it with your text editor, you will see something like this:

[submodule "externals/submodule"]
    path = externals/submodule
    url = git@github.com:Original/repo.git

Change the url to the updated location, rerun the git submodule sync and you should be good to go.

Michael Davis
  • 2,350
  • 2
  • 21
  • 29
  • Nope, the github.com URLs (which host the non-forked submodules) have been replaced properly, issue still exists – Jason May 24 '13 at 05:52
1

Once you have modified the .gitmodules file, a git submodule sync will only modify your .git/config, but won't change anything in .git/modules/yourSubmodule

That means a simple git submodule update yourSubmodule will still use the url stored in .git/modules/yourSubmodule/config, hence the 'old' url.

But if you do:

git submodule update --init yourSubmodule

Then the .git/modules/yourSubmodule is initialized again, with the proper new url, and the submodule is clones from that new url.

For that to work, I prefer deleting completely the submodule from my working tree first.

# restore an empty yourSubmodule directory
rm -Rf yourSubmodule ; git checkout -- yourSubmodule
# update .gitmodules
git submodule sync
git submodule update --init yourSubmodule
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
0

Check the URL setting in .gitmodules and your_submodule/.git/config.

neevek
  • 11,760
  • 8
  • 55
  • 73
  • I am having this same issue. I can confirm that my .gitmodule is the correct address. My .git/config inside the submodules folder also appears to be correct. Any updates here? – Thomas Oct 21 '14 at 18:27