我正在尝试根据这些说明更改子模块上的远程。在修改并保存
我还尝试了
我最初通过
.gitmodules
后,执行git submodule sync
,我的子模块没有发生变化,但是我的.git/config
文件已更新以匹配.gitmodules
中新的远程url。我还尝试了
git submodule sync --recursive
,并按照此提示执行rm -rf .git/modules/<mySubmodule>
,但没有任何变化。实际上,运行后者命令然后再次运行git submodule sync
会出现fatal: Not a git repository: ../.git/modules/<mySubmodule>
。有什么建议吗?我最初通过
git submodule add git://<mySubmodule-url>
将子模块添加到项目中,如git文档所述。
编辑
我甚至通过homebrew升级到v2.1.1,仍然没有任何变化。我还尝试完全从头开始,并在两个完全不同的子模块之间切换,但仍然得到相同的结果。总结:
$> 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>
git submodule update --init --recursive
是不行的(在执行了git submodule sync --recursive
之后)? - VonC