I have a forked repository that has three submodules, all of them are public but I want to change one of them for my own private repository. I clone the repository and after that I execute git submodule update --init
, git get the public ones, but with the private one git prompts a credential window that avoids downloading.
.submodule file
[submodule "saleor"]
path = saleor
url = https://github.com/mirumee/saleor.git
[submodule "saleor-storefront"] -> I want to replace this one with my private repo
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
Update 1
With the answer sugested by VonC, a new error occurred, the replaced submodule cannot be downloaded. How to reproduce this error:
- I fork saleor-platform repository.
- I clone on my machine the forked repository created on step 1:
D:gitestssaleor-platform>git clone https://github.com/<organization>/saleor-platform
- Create a new repository to replace
saleor-storefront
,saleor-storefront
is a submodule insaleor-platform
the repository forked on step 1. - Replace the submodule as VonC user suggest here, It should be noted that I want to change the
saleor-storefront
submodule for a private repo inside anorganization
, and it is a totally new implementation i.e. it only has the initial commit:
D:gitestssaleor-platform>git submodule set-url -- saleor-storefront https://github.com/<organization>/my-new-brand-implementation
- from the parent repository(
saleor-platform
) check new changes withgit status
, add new changesgit add .
, commit the changesgit commit -m "Update saleor-storefront submodule"
:
D:gitestssaleor-platform>git st
On branch master
Your branch is up to date with 'origin/master'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: .gitmodules
no changes added to commit (use "git add" and/or "git commit -a")
D:gitestssaleor-platform>git add .
D:gitestssaleor-platform>git commit -m "Update saleor-storefront submodule"
[master 53b60e5] Update saleor-storefront submodule
1 file changed, 1 insertion(+), 1 deletion(-)
- Push back to my fork:
D:gitestssaleor-platform>git push
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 8 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 353 bytes | 353.00 KiB/s, done.
Total 3 (delta 2), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (2/2), completed with 2 local objects.
To github.com:<organization>/saleor-platform.git
cbc31e4..53b60e5 master -> master
- Finally I clone again my repository:
D:gitests> git clone --recurse-submodules https://github.com/<organization>/saleor-platform saleor-platform2
Cloning into 'saleor-platform2'...
remote: Enumerating objects: 9, done.
remote: Counting objects: 100% (9/9), done.
remote: Compressing objects: 100% (9/9), done.
Receiving objects: 67% (138/205)), reused 3 (delta 0), pack-reused 196
Receiving objects: 100% (205/205), 68.41 KiB | 463.00 KiB/s, done.
Resolving deltas: 100% (99/99), done.
Submodule 'saleor' (https://github.com/mirumee/saleor.git) registered for path 'saleor'
Submodule 'saleor-dashboard' (https://github.com/mirumee/saleor-dashboard.git) registered for path 'saleor-dashboard'
Submodule 'saleor-storefront' (https://github.com/<organization>/my-new-brand-implementation) registered for path 'saleor-storefront'
Cloning into 'D:/git/tests/saleor-platform2/saleor'...
remote: Enumerating objects: 178730, done.
remote: Total 178730 (delta 0), reused 0 (delta 0), pack-reused 178730
Receiving objects: 100% (178730/178730), 100.26 MiB | 2.60 MiB/s, done.
Resolving deltas: 100% (130671/130671), done.
Cloning into 'D:/git/tests/saleor-platform2/saleor-dashboard'...
remote: Enumerating objects: 168, done.
remote: Counting objects: 100% (168/168), done.
remote: Compressing objects: 100% (132/132), done.
remote: Total 38062 (delta 69), reused 71 (delta 32), pack-reused 37894
Receiving objects: 100% (38062/38062), 24.61 MiB | 1.93 MiB/s, done.
Resolving deltas: 100% (25652/25652), done.
Cloning into 'D:/git/tests/saleor-platform2/saleor-storefront'...
remote: Enumerating objects: 113, done.
remote: Counting objects: 100% (113/113), done.
remote: Compressing objects: 100% (98/98), done.
remote: Total 113 (delta 2), reused 113 (delta 2), pack-reused 0
Receiving objects: 100% (113/113), 300.56 KiB | 523.00 KiB/s, done.
Resolving deltas: 100% (2/2), done.
Submodule path 'saleor': checked out '3b31391b92b184b591ef4e85ff6a59cd52cdad98'
Submodule path 'saleor-dashboard': checked out '8bcb8b70878078b74133aea0244dc840d75b492f'
fatal: remote error: upload-pack: not our ref 3ba4ffa8a14f90398462b84e5da088baeb84dfc6
fatal: the remote end hung up unexpectedly
Fetched in submodule path 'saleor-storefront', but it did not contain 3ba4ffa8a14f90398462b84e5da088baeb84dfc6. Direct fetching of that commit failed.