Does ../extern/Lib1
refer to a Git repository?
If it does not, Git wouldn't know how to had the Git repo url to its .gitmodule
Also, try:
- with the destination
lib
not already existing (even empty)
- with an absolute path instead of a relative path (you can use a relative one, but just in case, it is worth a try here)
Some good sources on submodules are:
Since only the absolute path works here, it means the relative path need a reference to be compared against.
That reference is the "remote origin" which should be in your DirName/NewRepo_withSubmodules/.git/config
file, like so:
$ cat .git/config
...
[remote "origin"]
url = /path/to/DirName/NewRepo_withSubmodules/.git
fetch = +refs/heads/*:refs/remotes/origin/*
...
If you do have that section in ../DirName/NewRepo_withSubmodules/.git/config
file, you should be able to add ../Extern/Lib1
as a submodule using a relative path.
All the above is inspired from the following section of the git submodule man page:
<repository>
is the URL of the new submodule's origin repository.
This may be either an absolute URL, or (if it begins with ./
or ../
), the location relative to the superproject's origin repository.
So if NewRepo_withSubmodules
is a local Git repo which has just been created (and has of course no "origin"), an artificial "remote origin" ought to be defined (even if the origin points to itself), if only to allow relative url for other submodule repositories to be used.