如何用不同的git代码库替换git子模块?
具体来说,我有一个子模块:
./ExternalFrameworks/TestFramework
,指向git repo git@github.com:userA/TestFramework.git
问题是,当我使用here描述的方法删除子模块时,然后使用以下命令重新添加它
git submodule add git@github.com:userB/TestFramework.git
我得到了这个错误:
A git directory for 'ExternalFrameworks/TestFramework' is found locally with remote(s):
origin git@github.com:userA/TestFramework.git
If you want to reuse this local git directory instead of cloning again from
git@github.com: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.
发布于 2013-01-19 02:45:14
如果子模块的位置(URL)已更改,则只需:
.gitmodule
文件修改为使用新的URLrm -rf <submodule>
git submodule sync
git submodule update
中的存储库rm -rf .git/modules/<submodule>
更完整的信息可以在其他地方找到:
发布于 2013-01-19 01:52:39
首先,使用前面提到的here方法删除当前的子模块,为了方便起见,我将其包括在内:
.gitmodules
文件中删除相关部分.git/config
git rm --cached path_to_submodule
中删除相关部分(不拖尾slash)现在,添加带有--name
标志的新子模块。这将为git提供一个备用名称,以便在.git/config
中为子模块引用,以便与历史上存在的子模块相冲突,而您仍然希望在以前的历史中使用它。
因此,键入:
git submodule add --name UpdatedTestFramework git@github.com:userB/TestFramework.git
然后,您将在您期望的路径上加载子模块。
发布于 2015-06-06 04:28:03
这些命令将在命令提示符上执行工作,而不会更改本地存储库中的任何文件。
git config --file=.gitmodules submodule.Submod.url https://github.com/username/ABC.git
git config --file=.gitmodules submodule.Submod.branch Dev
git submodule sync
git submodule update --init --recursive --remote
https://stackoverflow.com/questions/14404704
复制相似问题