Swap git submodule with own fork

后端 未结 2 792
遇见更好的自我
遇见更好的自我 2021-01-30 13:24

I added a submodule to my git repo like this:

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

I\'ve decided I want to creat

2条回答
  •  孤街浪徒
    2021-01-30 14:01

    I don’t know how long it is true, but certainly even in rather old git 1.8 submodules have remotes. So, you can do

    cd some-library   # this is entering the submodule
    git remote -v     # just to see what you have; I guess origin only
    git remote add myrepo git-URL-of-the-fork
    git checkout -b my_new_idea
    git push -u myrepo my_new_idea
    

    Now the submodule work with your fork instead of the original repo. You can do normal push, pull, rebase etc. When your pull request is merged, you can remove the remote with normal git remote remove myrepo. Of course, all other caveats about working with submodules apply (e.g., you have to commit the change of the submodule as a new commit in the supermodule).

提交回复
热议问题