Reputation: 6742
I have tried a lot of different answers on stack but none of them work. I am trying to add a repository as a submodule which contains another submodule. So what I do is this:
git submodule add -b develop [email protected]:submoduleRepo
The submodule is added to the repository and contains the folder of the submodule within it. However the folder is empty. So I follow up with this command:
git submodule update --init --recursive
Which returns me nothing. If I go to the directory of the submodule cd submoduleRepo
and then type git submodule, I get:
fatal: no submodule mapping found in .gitmodules for path 'src/app/nestedSubmoduleRepo'
This is my .gitmodules of the main repo:
[submodule "submoduleRepo"]
path = submoduleRepo
url = [email protected]:submoduleRepo.git
branch = develop
And within submoduleRepo/.gitmodules:
[submodule ".\\src\\app\\nestedSubmoduleRepo"]
path = .\\src\\app\\nestedSubmoduleRepo
url = [email protected]:nestedSubmoduleRepo.git
Why do I keep getting this error and is the directory not getting populated?
EDIT:
Once I've ran --init --recursive
once it gives me the error:
fatal: No url found for submodule path 'submoduleRepo/src/app/nestedSubmoduleRepo' in .gitmodules
Failed to recurse into submodule path 'submoduleRepo'
My git config:
[core]
repositoryformatversion = 0
filemode = false
bare = false
logallrefupdates = true
symlinks = false
ignorecase = true
[remote "origin"]
url = [email protected]:mainRepo.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
[submodule "submoduleRepo"]
url = [email protected]:submoduleRepo.git
active = true
Upvotes: 4
Views: 3076
Reputation: 76409
The problem is that your submodule repo is using backslashes in the .gitmodules
file. Git uses forward slashes for paths within the repository because they work across platforms (and backslashes do not), and it has no way of knowing whether your repository is intended to be cross platform or not.
You'll need to update the submodule repository to contain the proper entries in the file (and you should also drop the .
path component as well). Once you've committed that and updated the parent repository with the new commit, git submodule update --init --recursive
should work properly.
Upvotes: 5