Git/Github: Replace a submodule of a forked repository

爷,独闯天下 提交于 2021-02-20 01:58:18

问题


Whant I Want

I have an open source parent repository which I want to make a fork to work with it, this repository is composed of 3 submodules and some configuration files. What I want is to replace one of the submodules(saleor-storefront) with my own implementation(private repository) and I want to be able to update the other submodules and files with the changes made by the upstream repository.

Should I just change the path of the module I want to replace from the .gitmodules file or are there other changes involved that I'm not aware of?

Forked Project structure

saleor-platform
├── ./.gitmodules
├── ./common.env
├── ./docker-compose.yml
├── ./saleor
├── ./saleor-dashboard
└── ./saleor-storefront  -> Submodule to be replaced with my own implementation

.gitmodules

[submodule "saleor"]
    path = saleor
    url = https://github.com/mirumee/saleor.git
[submodule "saleor-storefront"]
    path = saleor-storefront
    url = https://github.com/mirumee/saleor-storefront.git
[submodule "saleor-dashboard"]
    path = saleor-dashboard
    url = https://github.com/mirumee/saleor-dashboard.git

回答1:


The Git 2.25 command git submodule set-url should help in order to update/replace the URL of one of your submodule by the one of your fork:

git submodule set-url -- saleor-storefront https://github.com/<me>/saleor-storefront

That way, you won't miss any "other changes" involved when modifying the URL of a submodule.



来源:https://stackoverflow.com/questions/65796573/git-github-replace-a-submodule-of-a-forked-repository

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!