Say I recursively clone a repo.
$ git clone --recursive ssh://server/project/client
Cloning into 'client'...
remote: Counting objects: 191, done
remote: Finding sources: 100% (191/191)
remote: Total 191 (delta 53), reused 159 (delta 53)
Receiving objects: 100% (191/191), 27.59 KiB | 0 bytes/s, done.
Resolving deltas: 100% (53/53), done.
Checking connectivity... done.
Submodule 'gui' (ssh://server/project/client/gui.git) registered for path 'gui'
Cloning into 'gui'...
remote: Counting objects: 3213, done
remote: Finding sources: 100% (3213/3213)
remote: Total 3213 (delta 1272), reused 3107 (delta 1272)
Receiving objects: 100% (3213/3213), 47.88 MiB | 12.05 MiB/s, done.
Resolving deltas: 100% (1272/1272), done.
Checking connectivity... done.
Submodule path 'gui': checked out '7315db8d7a8b36929f7874dc5477359839ec51ce'
Now I want to create a local clone of that local repo (perhaps after making and committing changes locally).
$ git clone --recursive client/ client_copy
Cloning into 'client_copy'...
done.
Submodule 'gui' (/home/deployer/client/gui.git) registered for path 'gui'
fatal: repository '/home/deployer/client/gui.git' does not exist
Clone of '/home/deployer/client/gui.git' into submodule path 'gui' failed
My .gitmodules
file looks like this:
[submodule "gui"]
path = gui
url = ../client/gui.git
Why does this fail, and how can I address the issue?
The issue is with your .gitmodules
file. The submodule url
in your project is defined as a relative path from the superproject repository, but when the submodules are cloned, they are placed using the path
location.
In other words, git is trying to pull the submodules from the url
location, but on your local machine, they're actually at the path
location.
To fix this, clone just the local superproject repository (git clone /path/to/superproject
), then go into the new clone's .gitsubmodules
and change the url
s to be ./<whatever-the-path-is>
. For example, your gui submodule would become:
[submodule "gui"]
path = gui
url = ./gui
Change each submodule in .gitmodules
to be like this, then run:
git submodule sync
git submodule update --init --recursive
and that should do it!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With