How to change the remote repository for a git submodule?

后端 未结 7 1188
醉梦人生
醉梦人生 2020-11-22 10:45

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

相关标签:
7条回答
  • 2020-11-22 11:34

    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.

    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
    
    0 讨论(0)
提交回复
热议问题