I've created a git repository with a submodule in it. I'm able to tell the submodule itself to change its remote repository path, but I'm not sure how to tell the parent repository how to change the remote repository path for the submodule.
I wouldn't be surprised if I'm somewhat out of luck and have to do things manually, as even deleting submodules isn't easy.
In order to update an existing Git submodule, you need to execute the “git submodule update” with the “–remote” and the “–merge” option. Using the “–remote” command, you will be able to update your existing Git submodules without having to run “git pull” commands in each submodule of your project.
Git Submodules Moving a submodule If needed, create the parent directory of the new location of the submodule ( mkdir -p new/path/to ). Move all content from the old to the new directory ( mv -vi old/path/to/module new/path/to/submodule ). Make sure Git tracks this directory ( git add new/path/to ).
If you want to make a change within a submodule, you should first check out a branch, make your changes, publish the change within the submodule, and then update the superproject to reference the new commit.
These commands will do the work on command prompt without altering any files on local repository
git config --file=.gitmodules submodule.Submod.url https://github.com/username/ABC.git git config --file=.gitmodules submodule.Submod.branch Development git submodule sync git submodule update --init --recursive --remote
Please look at the blog for screenshots: Changing GIT submodules URL/Branch to other URL/branch of same repository
You should just be able to edit the .gitmodules
file to update the URL and then run git submodule sync --recursive
to reflect that change to the superproject and your working copy.
Then you need to go to the .git/modules/path_to_submodule
dir and change its config file to update git path.
If repo history is different then you need to checkout new branch manually:
git submodule sync --recursive cd <submodule_dir> git fetch git checkout origin/master git branch master -f git checkout master
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With