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?

  • git clone: warning: --depth is ignored in local clones; use file:// instead
  • Merge and push all git branches
  • Force current commit to tip of branch
  • Gitlab job when tagging a release
  • Tortoise git fails with No supported authentication methods available (server sent: publickey)
  • Two-way git mirror
  • Two identical git repositories
  • Function in bash to commit and push in one command
  • How to completely clear git repository, without deleting it
  • Git. Undo staged changes in working directory, keeping staged area untouched
  • Redmine: see associated revisions for git branch?
  • how to add a private BitBucket git repository as repository / dependency in gradle?
  • One Solution collect form web for “Git submodule troubles – changing underlying repo address”

    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…

    Git Baby is a git and github fan, let's start git clone.