【发布时间】:2014-09-29 20:18:12
【问题描述】:
我正在尝试按照these instructions 更改子模块上的遥控器。
修改并保存.gitmodules,然后执行git submodule sync,我的子模块并没有改变,尽管我的.git/config文件已经更新以匹配.gitmodules中的新远程url。
我也试过git submodule sync --recursive,并按照this tip 做rm -rf .git/modules/<mySubmodule>,没有任何区别。事实上,运行后一个命令然后git submodule sync 再次给出fatal: Not a git repository: ../.git/modules/<mySubmodule>。有什么建议吗?
我最初按照git docs 将子模块通过git submodule add git://<mySubmodule-url> 添加到项目中。
编辑
我什至通过 homebrew 将 git 更新到 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之后)? -
不——我仍然看到原来的子模块。
标签: git git-submodules