如何用不同的 git 存储库替换 git 子模块?
具体来说,我有一个子模块:
- 位于
./ExternalFrameworks/TestFramework
指向 git repo[email protected]:userA/TestFramework.git
- 我现在希望它指向
[email protected]:userB/TestFramework.git
.
问题是当我用描述的方法删除子模块时here,然后使用命令重新添加它
git submodule add [email protected]:userB/TestFramework.git
我收到此错误:
A git directory for 'ExternalFrameworks/TestFramework' is found locally with remote(s):
origin [email protected]:userA/TestFramework.git
If you want to reuse this local git directory instead of cloning again from
[email protected]:userB/TestFramework.git
use the '--force' option. If the local git directory is not the correct repo
or you are unsure what this means choose another name with the '--name' option.
如果子模块的位置(URL)已更改,那么您可以简单地:
- 修改
.gitmodules
存储库根目录中的文件以使用新 URL。
- 删除存储库中的子模块文件夹
rm -rf .git/modules/<submodule>
.
- 删除工作目录下的子模块文件夹
rm -rf <submodule>
.
- Run
git submodule sync
.
- Run
git submodule update
.
更完整的信息可以在其他地方找到:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)