Git submodule synchronization not working

I am trying to change the remote on the submodule according to these instructions .

After modifying and saving .gitmodules , then running git submodule sync did not change my submodule, although my .git/config file was updated to match the new remote URL in .gitmodules .

I also tried git submodule sync --recursive and did rm -rf .git/modules/<mySubmodule> according to this rm -rf .git/modules/<mySubmodule> without any difference. Actually, by running the last command, git submodule sync again gives fatal: Not a git repository: ../.git/modules/<mySubmodule> . Any tips?

I initially added a submodule to the project via git submodule add git://<mySubmodule-url> according to git docs .

Edit

I even upgraded git via homebrew to v2.1.1, still nothing. I also tried starting from scratch, and even switching between two completely different submodules, but I still get the same results. In total:

 $> mkdir myRepo $> cd myRepo myRepo$> git init . myRepo$> git submodule add https://<path/to/my/repo>.git myRepo$> vim .gitmodules # change submodule url to https://<path/to/another/repo>.git myRepo$> git submodule sync # updates my .git/config file with the new submodule url, but all my files in the submodule are still from the old url myRepo$> git submodule sync --recursive # doesn't do anything myRepo$> git submodule update --init --recursive # doesn't do anything either myRepo$> rm -rf .git/modules/<mySubmodule> # tip from SO comment linked above myRepo$> git submodule sync fatal: Not a git repository: ../.git/modules/<mySubmodule> 
+5
source share
1 answer

It looks like annoyance. Not perfect, but it seems to work for me.

 git submodule foreach git pull --rebase 
+8
source

Source: https://habr.com/ru/post/1203649/


All Articles