Andrew Lauer Barinov
Andrew Lauer Barinov

Reputation: 5754

Git submodule troubles - changing underlying repo address

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?

Upvotes: 1

Views: 562

Answers (1)

VonC
VonC

Reputation: 1324937

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...

Upvotes: 2

Related Questions