用自己的fork交换git子模块 [英] Swap git submodule with own fork

查看:151
本文介绍了用自己的fork交换git子模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在git仓库中添加了一个子模块,如下所示:

I added a submodule to my git repo like this:

$ git submodule add git://github.com/user/some-library some-library

我已经决定要为该库创建一个分叉来进行一些调整.我该如何交换该子模块,使其指向我自己的github分支?

I've decided I want to create a fork of that library to do some adjustments. How can i swap that submodule so that it points to my own github fork instead?

推荐答案

子模块存储在.gitmodules:

$ cat .gitmodules
[submodule "ext/google-maps"]
    path = ext/google-maps
    url = git://git.naquadah.org/google-maps.git

如果使用文本编辑器编辑url,则需要运行以下命令:

If you edit the url with a text editor, you need to run the following:

$ git submodule sync

此更新.git/config包含此子模块列表的副本(您也可以手动编辑.git/config的相关[submodule]部分)

This updates .git/config which contains a copy of this submodule list (you could also just edit the relevant [submodule] section of .git/config manually)

虽然submodule系统似乎有点不完整,但是也许只有git命令可以做到这一点(例如,请参见

There might be a way to do it with only git commands, although the submodule system seems a bit incomplete (e.g see the instructions to remove a submodule)

这篇关于用自己的fork交换git子模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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