I have a git repo repoA
that is the parent repo. Within, I have a submodule repoB
stored at the directory repoB
within the cloned repoA
's directory.
Years ago, when I first started this project, I have been operating in the directory devDir
where repoA
is cloned to. To this day, I can push/fetch just fine within devDir
.
Recently, I wanted to clone another version of repoA
into demoDir
. The clone of repoA
into demoDir
works just fine, and I can see all of the correct files. Great!
Now when I do a git submodule update --init
I am hit with this error message:
user@devBox:~/repos/demoDir> git submodule update --init
Cloning into '/home/user/repos/demoDir/repoB'...
remote:
remote: ========================================================================
remote:
remote: ERROR: The namespace you were looking for could not be found.
remote:
remote: ========================================================================
remote:
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
fatal: clone of 'git@gitlab.com:groupname/repoA.git/repoB' into submodule path '/home/user/repos/demoDir/repoB' failed
When I cat demoDir/.gitmodules
I see
[submodule "repoB"]
path = repoB
url = ./repoB/
which is fine.
Then, when I cat demoDir/.git/config
I see
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
url = git@gitlab.com:groupname/repoA.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
[submodule "repoB"]
active = true
url = git@gitlab.com:groupname/repoA.git/repoB
Now that last url line is worrisome to me, as that is not the correct path to clone repoB
from ( when I go to gitlab's website and click the clone button, the url it gives me is git@gitlab.com:groupname/repoB.git
).
When I edit demoDir/.git/config
and change that last line to url = git@gitlab.com:groupname/repoB.git
, I can then run git submodule update --init
and it is able to check everything out just fine.
The real kicker here, is when I cat devDir/.git/config
I get basically the exact same output (for the submodule) as demoDir
, except it's flipped
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
url = git@gitlab.com:groupname/repoA.git
fetch = +refs/heads/*:refs/remotes/origin/*
pushurl = git@gitlab.com:groupname/repoA.git
[branch "master"]
remote = origin
merge = refs/heads/master
[submodule "repoB"]
url = git@gitlab.com:groupname/repoA.git/repoB
active = true
[... a bunch of branches that I don't think matter]
So how in the HECK can one clone work fine, and the other not?
I've tried running a git submodule sync
but no dice.
Things I've ruled out:
repoA
just fine.demoDir/.gitmodules
and demoDir/.git/config
actually exist from within the browser on gitlab's site.Any and all help is appreciated!
De-initializing my submodules, and then re-initializing them worked. How did I do that?
De-init: https://www.educative.io/answers/how-to-delete-a-git-submodule
Add:
git submodule add git@gitlab.com:groupname/repoB.git repoB
I then committed these changes and verified that I was able to clone fresh.