1

I have a project where I added a git submodule to a fork of a repo that is out of date. Rather than pointing to that fork, I decided to change the submodule reference to point to the original repo instead.

I edited the .gitmodules file to reflect the new reference and ran git submodule init and git submodule update --recursive however there is no effect, am I missing a step here?

Andrew Lauer Barinov
  • 5,694
  • 10
  • 59
  • 83

1 Answers1

2

neevek mentions .git/config, and the documentation of git config confirms:

submodule..path submodule..url submodule..update

The path within this project, URL, and the updating strategy for a submodule.
These variables are initially populated by git submodule init; edit them to override the URL and other values found in the .gitmodules file.

So:

  • changing the values in the .gitmodules alone isn't enough (the url in the .git/config will have precedence).
  • git submodule init, as the documentation mentions, does not alter existing information in .git/config (and that explains why your commands didn't have any visible effect).
    You can then customize the submodule clone URLs in .git/config for your local setup and proceed to git submodule update.

I personally find this url duplication a bit confusing...

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • I tried this approach, and after updating the `config` URL to the original repo, I am still not able to get `git submodule update` to work. Really nice find though. – Andrew Lauer Barinov Mar 05 '13 at 16:20
  • What's worse is I followed the steps here as well: http://stackoverflow.com/questions/14404704/how-do-i-replace-a-git-submodule-with-another-repo and `git submodule sync` doesn't work either. Git is just acting like a total git today (sorry couldn't help myself) – Andrew Lauer Barinov Mar 05 '13 at 16:33