问题
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