如何更改git子模块的远程存储库? [英] How to change the remote repository for a git submodule?

查看:126
本文介绍了如何更改git子模块的远程存储库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个git存储库,其中包含一个子模块.我能够告诉子模块本身更改其远程存储库路径,但是我不确定如何告诉父存储库如何更改子模块的远程存储库路径.

I've created a git repository with a submodule in it. I'm able to tell the submodule itself to change its remote repository path, but I'm not sure how to tell the parent repository how to change the remote repository path for the submodule.

如果我有点不走运并且必须手动执行操作,我不会感到惊讶,因为即使删除子模块也不容易.

I wouldn't be surprised if I'm somewhat out of luck and have to do things manually, as even deleting submodules isn't easy.

推荐答案

您应该只能够编辑.gitmodules文件以更新URL,然后运行git submodule sync --recursive将该更改反映到超级项目和工作副本中.

You should just be able to edit the .gitmodules file to update the URL and then run git submodule sync --recursive to reflect that change to the superproject and your working copy.

然后,您需要转到.git/modules/path_to_submodule目录并更改其配置文件以更新git路径.

Then you need to go to the .git/modules/path_to_submodule dir and change its config file to update git path.

如果回购历史记录不同,那么您需要手动签出新分支:

If repo history is different then you need to checkout new branch manually:

git submodule sync --recursive
cd <submodule_dir> 

git fetch
git checkout origin/master
git branch master -f
git checkout master

这篇关于如何更改git子模块的远程存储库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆