This is my .gitmodules
:
[submodule "app/code/EthanYehuda/CronjobManager"]
path = app/code/EthanYehuda/CronjobManager
url = https://[email protected]/some_user/ethanyehuda_cronjobmanager.git
I need to change the url to https://github.com/Ethan3600/magento2-CronjobManager.git
So I just changed it:
[submodule "app/code/EthanYehuda/CronjobManager"]
path = app/code/EthanYehuda/CronjobManager
url = https://github.com/Ethan3600/magento2-CronjobManager.git
Then I added the file to the staging area and made a commit:
git add .gitmodules
git commit -m "change url of submodule xy"
Then I executed git submodule update --init
. But if I go to app/code/EthanYehuda/CronjobManager
and show the remote, then I still get https://[email protected]/some_user/ethanyehuda_cronjobmanager.git
.gitmodules
holds the suggested defaults, your changes will take effect when setting up subsequent clones.
Once somebody has done the clone though, the resulting repository's just a repository. You can go in to your existing submodule's directory and change its origin remote url the usual way, but the git submodule
command has a handy shortcut,
git submodule sync
to fill in all the blanks for you.
sync [--recursive] [--] [<path>…]
Synchronizes submodules' remote URL configuration setting to the value specified in
.gitmodules
. It will only affect those submodules which already have a URL entry in.git/config
(that is the case when they are initialized or freshly added). This is useful when submodule URLs change upstream and you need to update your local repositories accordingly.
git submodule sync
synchronizes all submodules whilegit submodule sync -- A
synchronizes submodule "A" only.If
--recursive
is specified, this command will recurse into the registered submodules, and sync any nested submodules within.
Since git v2.25.0 (changelog), git submodule
learn the new set-url command.
To use it simply do git submodule set-url -- <path> <url>
For you it is:
git submodule set-url -- app/code/EthanYehuda/CronjobManager https://github.com/Ethan3600/magento2-CronjobManager.git
Note: wherever you are in your git the path should be relative to the top directory.
See this answer for more information.
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
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