用自己的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)