Can't add git submodule when specified as a relative path
I'm trying to add a submodule to my git repo, and I'm getting this error in return:
remote origin does not have a url defined in .git/config
any ideas about what this might be? I tried googling for it but only one vague link comes up.
I'm doing this:
git submodule add ../extern/Lib1 lib
I'm expecting this to create a submodule lib/Lib1
I'm aware that this will only create a reference and that I then have to update/init (not crystal clear on this part, haven't gotten that far; I'm just learning the submodule command).
git git-submodules
add a comment |
I'm trying to add a submodule to my git repo, and I'm getting this error in return:
remote origin does not have a url defined in .git/config
any ideas about what this might be? I tried googling for it but only one vague link comes up.
I'm doing this:
git submodule add ../extern/Lib1 lib
I'm expecting this to create a submodule lib/Lib1
I'm aware that this will only create a reference and that I then have to update/init (not crystal clear on this part, haven't gotten that far; I'm just learning the submodule command).
git git-submodules
Just completed my answer with additional suggestions
– VonC
Dec 29 '09 at 12:28
I think the absolute path works here only because yourextern/Lib1
Git repo ... does not have a "remote origin does not have a url defined in.git/config
" ;). Some investigation in that .git/config is in order.
– VonC
Dec 29 '09 at 12:42
not sure what you mean. I just looked at extern/Lib1's .git/config and all it has is the [core] section: repositoryformatversion=0,filemode=true,bare=false,legalrefupdates=true
– deepblue
Dec 29 '09 at 12:47
Just added an example about where exactly that "remote origin" should be defined. See my edited answer.
– VonC
Dec 29 '09 at 12:47
Your last comment made me re-read the git submodule man page. I have edited my answer for a more exact location of the relevant.git/config
file.
– VonC
Dec 29 '09 at 13:30
add a comment |
I'm trying to add a submodule to my git repo, and I'm getting this error in return:
remote origin does not have a url defined in .git/config
any ideas about what this might be? I tried googling for it but only one vague link comes up.
I'm doing this:
git submodule add ../extern/Lib1 lib
I'm expecting this to create a submodule lib/Lib1
I'm aware that this will only create a reference and that I then have to update/init (not crystal clear on this part, haven't gotten that far; I'm just learning the submodule command).
git git-submodules
I'm trying to add a submodule to my git repo, and I'm getting this error in return:
remote origin does not have a url defined in .git/config
any ideas about what this might be? I tried googling for it but only one vague link comes up.
I'm doing this:
git submodule add ../extern/Lib1 lib
I'm expecting this to create a submodule lib/Lib1
I'm aware that this will only create a reference and that I then have to update/init (not crystal clear on this part, haven't gotten that far; I'm just learning the submodule command).
git git-submodules
git git-submodules
edited Feb 28 '12 at 7:16
Mechanical snail
19.2k87198
19.2k87198
asked Dec 29 '09 at 11:33
deepblue
3,670104258
3,670104258
Just completed my answer with additional suggestions
– VonC
Dec 29 '09 at 12:28
I think the absolute path works here only because yourextern/Lib1
Git repo ... does not have a "remote origin does not have a url defined in.git/config
" ;). Some investigation in that .git/config is in order.
– VonC
Dec 29 '09 at 12:42
not sure what you mean. I just looked at extern/Lib1's .git/config and all it has is the [core] section: repositoryformatversion=0,filemode=true,bare=false,legalrefupdates=true
– deepblue
Dec 29 '09 at 12:47
Just added an example about where exactly that "remote origin" should be defined. See my edited answer.
– VonC
Dec 29 '09 at 12:47
Your last comment made me re-read the git submodule man page. I have edited my answer for a more exact location of the relevant.git/config
file.
– VonC
Dec 29 '09 at 13:30
add a comment |
Just completed my answer with additional suggestions
– VonC
Dec 29 '09 at 12:28
I think the absolute path works here only because yourextern/Lib1
Git repo ... does not have a "remote origin does not have a url defined in.git/config
" ;). Some investigation in that .git/config is in order.
– VonC
Dec 29 '09 at 12:42
not sure what you mean. I just looked at extern/Lib1's .git/config and all it has is the [core] section: repositoryformatversion=0,filemode=true,bare=false,legalrefupdates=true
– deepblue
Dec 29 '09 at 12:47
Just added an example about where exactly that "remote origin" should be defined. See my edited answer.
– VonC
Dec 29 '09 at 12:47
Your last comment made me re-read the git submodule man page. I have edited my answer for a more exact location of the relevant.git/config
file.
– VonC
Dec 29 '09 at 13:30
Just completed my answer with additional suggestions
– VonC
Dec 29 '09 at 12:28
Just completed my answer with additional suggestions
– VonC
Dec 29 '09 at 12:28
I think the absolute path works here only because your
extern/Lib1
Git repo ... does not have a "remote origin does not have a url defined in .git/config
" ;). Some investigation in that .git/config is in order.– VonC
Dec 29 '09 at 12:42
I think the absolute path works here only because your
extern/Lib1
Git repo ... does not have a "remote origin does not have a url defined in .git/config
" ;). Some investigation in that .git/config is in order.– VonC
Dec 29 '09 at 12:42
not sure what you mean. I just looked at extern/Lib1's .git/config and all it has is the [core] section: repositoryformatversion=0,filemode=true,bare=false,legalrefupdates=true
– deepblue
Dec 29 '09 at 12:47
not sure what you mean. I just looked at extern/Lib1's .git/config and all it has is the [core] section: repositoryformatversion=0,filemode=true,bare=false,legalrefupdates=true
– deepblue
Dec 29 '09 at 12:47
Just added an example about where exactly that "remote origin" should be defined. See my edited answer.
– VonC
Dec 29 '09 at 12:47
Just added an example about where exactly that "remote origin" should be defined. See my edited answer.
– VonC
Dec 29 '09 at 12:47
Your last comment made me re-read the git submodule man page. I have edited my answer for a more exact location of the relevant
.git/config
file.– VonC
Dec 29 '09 at 13:30
Your last comment made me re-read the git submodule man page. I have edited my answer for a more exact location of the relevant
.git/config
file.– VonC
Dec 29 '09 at 13:30
add a comment |
3 Answers
3
active
oldest
votes
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:
- chapter 8 of Git User's manual
Wiki page on Git Submodule Tutorial
and of course- Git submodule man page
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'sorigin
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.
Git 2.13 (Q2 2017) will improve the detection of the default origin of a submodule.
See commit d1b3b81 (25 Feb 2017) by Stefan Beller (stefanbeller
).
(Merged by Junio C Hamano -- gitster
-- in commit ae900eb, 10 Mar 2017)
submodule init
: warn about falling back to a local path
As now documented:
<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 default remote repository
(Please note that to specify a repository 'foo.git
' which is located right next to a superproject 'bar.git
', you'll have to use '../foo.git
' instead of './foo.git
' - as one might expect when following the rules for relative URLs - because the evaluation of relative URLs in Git is identical to that of relative directories).
The default remote is the remote of the remote tracking branch of the current branch.
If no such remote tracking branch exists or theHEAD
is detached, "origin
" is assumed to be the default remote.
If the superproject doesn't have a default remote configured the superproject is its own authoritative upstream and the current.
working directory is used instead.
Git 2.20 (Q4 2018) improves local path support for submodules.
See commit e0a862f (16 Oct 2018) by Stefan Beller (stefanbeller
).
(Merged by Junio C Hamano -- gitster
-- in commit 3fc8522, 06 Nov 2018)
submodule helper
: convert relative URL to absolute URL if needed
The submodule helper
update_clone
called by "git submodule update
",
clones submodules if needed.
As submodules used to have the URL indicating if they were active, the step to resolve relative URLs was done in the "submodule init
" step. Nowadays submodules can be configured active without calling an explicit init, e.g. via configuringsubmodule.active
.
When trying to obtain submodules that are set active this way, we'll
fallback to the URL found in the.gitmodules
, which may be relative to the
superproject, but we do not resolve it, yet:
git clone https://gerrit.googlesource.com/gerrit
cd gerrit && grep url .gitmodules
url = ../plugins/codemirror-editor
...
git config submodule.active .
git submodule update
fatal: repository '../plugins/codemirror-editor' does not exist
fatal: clone of '../plugins/codemirror-editor' into submodule path '/tmp/gerrit/plugins/codemirror-editor' failed
Failed to clone 'plugins/codemirror-editor'. Retry scheduled
[...]
fatal: clone of '../plugins/codemirror-editor' into submodule path '/tmp/gerrit/plugins/codemirror-editor' failed
Failed to clone 'plugins/codemirror-editor' a second time, aborting
[...]
To resolve the issue, factor out the function that resolves the relative
URLs in "git submodule init
" (in the submodule helper in theinit_submodule
function) and call it at the appropriate place in theupdate_clone
helper.
yep it does. the ./lib folder is empty tho (in "git submodule add ../extern/Lib1 lib")
– deepblue
Dec 29 '09 at 12:25
3
damn. ok, so the absolute path worked, the relative does not... this is not mentioned anywhere (I've been reading tutorials for hours and they all use web URL's as examples). the problem with this is when someone else clones my repos, and does not have the correct dir nesting, the 'submodule init/update' wont work for them... any ideas? thanks Von, appreciate it
– deepblue
Dec 29 '09 at 12:33
will do as you suggest. question: doesnt this just move the absolute path from the super-repo (one into which we're placing the submodule) into the repo referenced by the submodule? in my case both the superrepo and the referenced repo (from inside the submodule) are in the same master dir DirName (DirName/extern/Lib1 & DirName/NewRepo_withSubmodules). So I would prefer to be able to move that master dir (DirName) around without configs inside it breaking.
– deepblue
Dec 29 '09 at 12:59
Good question, which made me revisit the.git/config
file location. See my edited answer.
– VonC
Dec 29 '09 at 13:29
1
great! so it worked. in order to use relative paths to the external submodule I had to first do the following (on a fresh - noncloned repo): "git remote add origin .." and then "git submodule add ../extern/LibName lib". thanks again Vic!
– deepblue
Dec 29 '09 at 14:14
|
show 4 more comments
I was trying the same thing, and found the following 'seems to have worked:
I have (on windows):
D:/phd/analyses
/analysis1/ #This is an existing repository
/analysis2/ #another existing repository
/analysis3.tex
/analysis4.tex
...
/analysisN.tex
analysis1.tex ... analysisN.tex
contain ideas I've not worked on yet ('stubs, say), and analysis1/
and analysis2/
are things I am working on (and hence have code, tex, ... in them). Once I get around to working on the other analyses, they will get moved to their own folders and hence their own repositories.
What I did was (in git bash in analyses):
git init
git add *.tex
git remote add self .
git submodule add self:/analysis2/.git analysis2
git submodule add self:/analysis5/.git analysis5
git commit -m "Initial commit"
This seems to have worked.
D:/phd/analyses/.git/config
looks like it should, and .gitmodules
looks like:
[submodule "analysis2"]
path = analysis2
url = self:analysis2/.git
[submodule "analysis5"]
path = analysis5
url = self:analysis5/.git
Regards,
Simon Knapp
2
Doesn't work for me (on Linux). It tries to access the computerself
over the Internet.
– Mechanical snail
Feb 28 '12 at 4:07
also does not work on darwin: …[852]$ git submodule add -b myBranch self:../relativeRepo Cloning into relativeRepo...
ssh: Could not resolve hostname self: nodename nor servname provided, or not known fatal: The remote end hung up unexpectedly` Clone of 'self:../relativeRepo' into submodule path 'relativeRepo' failed
– john.k.doe
May 4 '12 at 18:26
add a comment |
(I've summarized just the solution here. Credit goes to VonC.)
In the containing repository (say containing.git/
), git
interprets relative paths as relative to the origin
remote, which is not defined. We want it to be relative to the containing.git/
directory, so run
git remote add origin ..
(Not sure why it's ..
rather than .
.)
Now you can add the sub-module:
git submodule add ../extern/Lib1 lib
This didn't work for me - it still tried to look up../extern/Lib1
in the local path. I had to dogit remote rename myrem origin
, thengit submodule add ../extern/Lib1 lib
, thengit remote rename origin myrem
andgit submodule foreach git remote rename origin myrem
– M.M
Apr 21 '16 at 8:42
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f1974181%2fcant-add-git-submodule-when-specified-as-a-relative-path%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
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:
- chapter 8 of Git User's manual
Wiki page on Git Submodule Tutorial
and of course- Git submodule man page
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'sorigin
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.
Git 2.13 (Q2 2017) will improve the detection of the default origin of a submodule.
See commit d1b3b81 (25 Feb 2017) by Stefan Beller (stefanbeller
).
(Merged by Junio C Hamano -- gitster
-- in commit ae900eb, 10 Mar 2017)
submodule init
: warn about falling back to a local path
As now documented:
<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 default remote repository
(Please note that to specify a repository 'foo.git
' which is located right next to a superproject 'bar.git
', you'll have to use '../foo.git
' instead of './foo.git
' - as one might expect when following the rules for relative URLs - because the evaluation of relative URLs in Git is identical to that of relative directories).
The default remote is the remote of the remote tracking branch of the current branch.
If no such remote tracking branch exists or theHEAD
is detached, "origin
" is assumed to be the default remote.
If the superproject doesn't have a default remote configured the superproject is its own authoritative upstream and the current.
working directory is used instead.
Git 2.20 (Q4 2018) improves local path support for submodules.
See commit e0a862f (16 Oct 2018) by Stefan Beller (stefanbeller
).
(Merged by Junio C Hamano -- gitster
-- in commit 3fc8522, 06 Nov 2018)
submodule helper
: convert relative URL to absolute URL if needed
The submodule helper
update_clone
called by "git submodule update
",
clones submodules if needed.
As submodules used to have the URL indicating if they were active, the step to resolve relative URLs was done in the "submodule init
" step. Nowadays submodules can be configured active without calling an explicit init, e.g. via configuringsubmodule.active
.
When trying to obtain submodules that are set active this way, we'll
fallback to the URL found in the.gitmodules
, which may be relative to the
superproject, but we do not resolve it, yet:
git clone https://gerrit.googlesource.com/gerrit
cd gerrit && grep url .gitmodules
url = ../plugins/codemirror-editor
...
git config submodule.active .
git submodule update
fatal: repository '../plugins/codemirror-editor' does not exist
fatal: clone of '../plugins/codemirror-editor' into submodule path '/tmp/gerrit/plugins/codemirror-editor' failed
Failed to clone 'plugins/codemirror-editor'. Retry scheduled
[...]
fatal: clone of '../plugins/codemirror-editor' into submodule path '/tmp/gerrit/plugins/codemirror-editor' failed
Failed to clone 'plugins/codemirror-editor' a second time, aborting
[...]
To resolve the issue, factor out the function that resolves the relative
URLs in "git submodule init
" (in the submodule helper in theinit_submodule
function) and call it at the appropriate place in theupdate_clone
helper.
yep it does. the ./lib folder is empty tho (in "git submodule add ../extern/Lib1 lib")
– deepblue
Dec 29 '09 at 12:25
3
damn. ok, so the absolute path worked, the relative does not... this is not mentioned anywhere (I've been reading tutorials for hours and they all use web URL's as examples). the problem with this is when someone else clones my repos, and does not have the correct dir nesting, the 'submodule init/update' wont work for them... any ideas? thanks Von, appreciate it
– deepblue
Dec 29 '09 at 12:33
will do as you suggest. question: doesnt this just move the absolute path from the super-repo (one into which we're placing the submodule) into the repo referenced by the submodule? in my case both the superrepo and the referenced repo (from inside the submodule) are in the same master dir DirName (DirName/extern/Lib1 & DirName/NewRepo_withSubmodules). So I would prefer to be able to move that master dir (DirName) around without configs inside it breaking.
– deepblue
Dec 29 '09 at 12:59
Good question, which made me revisit the.git/config
file location. See my edited answer.
– VonC
Dec 29 '09 at 13:29
1
great! so it worked. in order to use relative paths to the external submodule I had to first do the following (on a fresh - noncloned repo): "git remote add origin .." and then "git submodule add ../extern/LibName lib". thanks again Vic!
– deepblue
Dec 29 '09 at 14:14
|
show 4 more comments
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:
- chapter 8 of Git User's manual
Wiki page on Git Submodule Tutorial
and of course- Git submodule man page
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'sorigin
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.
Git 2.13 (Q2 2017) will improve the detection of the default origin of a submodule.
See commit d1b3b81 (25 Feb 2017) by Stefan Beller (stefanbeller
).
(Merged by Junio C Hamano -- gitster
-- in commit ae900eb, 10 Mar 2017)
submodule init
: warn about falling back to a local path
As now documented:
<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 default remote repository
(Please note that to specify a repository 'foo.git
' which is located right next to a superproject 'bar.git
', you'll have to use '../foo.git
' instead of './foo.git
' - as one might expect when following the rules for relative URLs - because the evaluation of relative URLs in Git is identical to that of relative directories).
The default remote is the remote of the remote tracking branch of the current branch.
If no such remote tracking branch exists or theHEAD
is detached, "origin
" is assumed to be the default remote.
If the superproject doesn't have a default remote configured the superproject is its own authoritative upstream and the current.
working directory is used instead.
Git 2.20 (Q4 2018) improves local path support for submodules.
See commit e0a862f (16 Oct 2018) by Stefan Beller (stefanbeller
).
(Merged by Junio C Hamano -- gitster
-- in commit 3fc8522, 06 Nov 2018)
submodule helper
: convert relative URL to absolute URL if needed
The submodule helper
update_clone
called by "git submodule update
",
clones submodules if needed.
As submodules used to have the URL indicating if they were active, the step to resolve relative URLs was done in the "submodule init
" step. Nowadays submodules can be configured active without calling an explicit init, e.g. via configuringsubmodule.active
.
When trying to obtain submodules that are set active this way, we'll
fallback to the URL found in the.gitmodules
, which may be relative to the
superproject, but we do not resolve it, yet:
git clone https://gerrit.googlesource.com/gerrit
cd gerrit && grep url .gitmodules
url = ../plugins/codemirror-editor
...
git config submodule.active .
git submodule update
fatal: repository '../plugins/codemirror-editor' does not exist
fatal: clone of '../plugins/codemirror-editor' into submodule path '/tmp/gerrit/plugins/codemirror-editor' failed
Failed to clone 'plugins/codemirror-editor'. Retry scheduled
[...]
fatal: clone of '../plugins/codemirror-editor' into submodule path '/tmp/gerrit/plugins/codemirror-editor' failed
Failed to clone 'plugins/codemirror-editor' a second time, aborting
[...]
To resolve the issue, factor out the function that resolves the relative
URLs in "git submodule init
" (in the submodule helper in theinit_submodule
function) and call it at the appropriate place in theupdate_clone
helper.
yep it does. the ./lib folder is empty tho (in "git submodule add ../extern/Lib1 lib")
– deepblue
Dec 29 '09 at 12:25
3
damn. ok, so the absolute path worked, the relative does not... this is not mentioned anywhere (I've been reading tutorials for hours and they all use web URL's as examples). the problem with this is when someone else clones my repos, and does not have the correct dir nesting, the 'submodule init/update' wont work for them... any ideas? thanks Von, appreciate it
– deepblue
Dec 29 '09 at 12:33
will do as you suggest. question: doesnt this just move the absolute path from the super-repo (one into which we're placing the submodule) into the repo referenced by the submodule? in my case both the superrepo and the referenced repo (from inside the submodule) are in the same master dir DirName (DirName/extern/Lib1 & DirName/NewRepo_withSubmodules). So I would prefer to be able to move that master dir (DirName) around without configs inside it breaking.
– deepblue
Dec 29 '09 at 12:59
Good question, which made me revisit the.git/config
file location. See my edited answer.
– VonC
Dec 29 '09 at 13:29
1
great! so it worked. in order to use relative paths to the external submodule I had to first do the following (on a fresh - noncloned repo): "git remote add origin .." and then "git submodule add ../extern/LibName lib". thanks again Vic!
– deepblue
Dec 29 '09 at 14:14
|
show 4 more comments
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:
- chapter 8 of Git User's manual
Wiki page on Git Submodule Tutorial
and of course- Git submodule man page
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'sorigin
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.
Git 2.13 (Q2 2017) will improve the detection of the default origin of a submodule.
See commit d1b3b81 (25 Feb 2017) by Stefan Beller (stefanbeller
).
(Merged by Junio C Hamano -- gitster
-- in commit ae900eb, 10 Mar 2017)
submodule init
: warn about falling back to a local path
As now documented:
<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 default remote repository
(Please note that to specify a repository 'foo.git
' which is located right next to a superproject 'bar.git
', you'll have to use '../foo.git
' instead of './foo.git
' - as one might expect when following the rules for relative URLs - because the evaluation of relative URLs in Git is identical to that of relative directories).
The default remote is the remote of the remote tracking branch of the current branch.
If no such remote tracking branch exists or theHEAD
is detached, "origin
" is assumed to be the default remote.
If the superproject doesn't have a default remote configured the superproject is its own authoritative upstream and the current.
working directory is used instead.
Git 2.20 (Q4 2018) improves local path support for submodules.
See commit e0a862f (16 Oct 2018) by Stefan Beller (stefanbeller
).
(Merged by Junio C Hamano -- gitster
-- in commit 3fc8522, 06 Nov 2018)
submodule helper
: convert relative URL to absolute URL if needed
The submodule helper
update_clone
called by "git submodule update
",
clones submodules if needed.
As submodules used to have the URL indicating if they were active, the step to resolve relative URLs was done in the "submodule init
" step. Nowadays submodules can be configured active without calling an explicit init, e.g. via configuringsubmodule.active
.
When trying to obtain submodules that are set active this way, we'll
fallback to the URL found in the.gitmodules
, which may be relative to the
superproject, but we do not resolve it, yet:
git clone https://gerrit.googlesource.com/gerrit
cd gerrit && grep url .gitmodules
url = ../plugins/codemirror-editor
...
git config submodule.active .
git submodule update
fatal: repository '../plugins/codemirror-editor' does not exist
fatal: clone of '../plugins/codemirror-editor' into submodule path '/tmp/gerrit/plugins/codemirror-editor' failed
Failed to clone 'plugins/codemirror-editor'. Retry scheduled
[...]
fatal: clone of '../plugins/codemirror-editor' into submodule path '/tmp/gerrit/plugins/codemirror-editor' failed
Failed to clone 'plugins/codemirror-editor' a second time, aborting
[...]
To resolve the issue, factor out the function that resolves the relative
URLs in "git submodule init
" (in the submodule helper in theinit_submodule
function) and call it at the appropriate place in theupdate_clone
helper.
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:
- chapter 8 of Git User's manual
Wiki page on Git Submodule Tutorial
and of course- Git submodule man page
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'sorigin
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.
Git 2.13 (Q2 2017) will improve the detection of the default origin of a submodule.
See commit d1b3b81 (25 Feb 2017) by Stefan Beller (stefanbeller
).
(Merged by Junio C Hamano -- gitster
-- in commit ae900eb, 10 Mar 2017)
submodule init
: warn about falling back to a local path
As now documented:
<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 default remote repository
(Please note that to specify a repository 'foo.git
' which is located right next to a superproject 'bar.git
', you'll have to use '../foo.git
' instead of './foo.git
' - as one might expect when following the rules for relative URLs - because the evaluation of relative URLs in Git is identical to that of relative directories).
The default remote is the remote of the remote tracking branch of the current branch.
If no such remote tracking branch exists or theHEAD
is detached, "origin
" is assumed to be the default remote.
If the superproject doesn't have a default remote configured the superproject is its own authoritative upstream and the current.
working directory is used instead.
Git 2.20 (Q4 2018) improves local path support for submodules.
See commit e0a862f (16 Oct 2018) by Stefan Beller (stefanbeller
).
(Merged by Junio C Hamano -- gitster
-- in commit 3fc8522, 06 Nov 2018)
submodule helper
: convert relative URL to absolute URL if needed
The submodule helper
update_clone
called by "git submodule update
",
clones submodules if needed.
As submodules used to have the URL indicating if they were active, the step to resolve relative URLs was done in the "submodule init
" step. Nowadays submodules can be configured active without calling an explicit init, e.g. via configuringsubmodule.active
.
When trying to obtain submodules that are set active this way, we'll
fallback to the URL found in the.gitmodules
, which may be relative to the
superproject, but we do not resolve it, yet:
git clone https://gerrit.googlesource.com/gerrit
cd gerrit && grep url .gitmodules
url = ../plugins/codemirror-editor
...
git config submodule.active .
git submodule update
fatal: repository '../plugins/codemirror-editor' does not exist
fatal: clone of '../plugins/codemirror-editor' into submodule path '/tmp/gerrit/plugins/codemirror-editor' failed
Failed to clone 'plugins/codemirror-editor'. Retry scheduled
[...]
fatal: clone of '../plugins/codemirror-editor' into submodule path '/tmp/gerrit/plugins/codemirror-editor' failed
Failed to clone 'plugins/codemirror-editor' a second time, aborting
[...]
To resolve the issue, factor out the function that resolves the relative
URLs in "git submodule init
" (in the submodule helper in theinit_submodule
function) and call it at the appropriate place in theupdate_clone
helper.
edited Nov 11 at 2:09
answered Dec 29 '09 at 12:23
VonC
828k28726073150
828k28726073150
yep it does. the ./lib folder is empty tho (in "git submodule add ../extern/Lib1 lib")
– deepblue
Dec 29 '09 at 12:25
3
damn. ok, so the absolute path worked, the relative does not... this is not mentioned anywhere (I've been reading tutorials for hours and they all use web URL's as examples). the problem with this is when someone else clones my repos, and does not have the correct dir nesting, the 'submodule init/update' wont work for them... any ideas? thanks Von, appreciate it
– deepblue
Dec 29 '09 at 12:33
will do as you suggest. question: doesnt this just move the absolute path from the super-repo (one into which we're placing the submodule) into the repo referenced by the submodule? in my case both the superrepo and the referenced repo (from inside the submodule) are in the same master dir DirName (DirName/extern/Lib1 & DirName/NewRepo_withSubmodules). So I would prefer to be able to move that master dir (DirName) around without configs inside it breaking.
– deepblue
Dec 29 '09 at 12:59
Good question, which made me revisit the.git/config
file location. See my edited answer.
– VonC
Dec 29 '09 at 13:29
1
great! so it worked. in order to use relative paths to the external submodule I had to first do the following (on a fresh - noncloned repo): "git remote add origin .." and then "git submodule add ../extern/LibName lib". thanks again Vic!
– deepblue
Dec 29 '09 at 14:14
|
show 4 more comments
yep it does. the ./lib folder is empty tho (in "git submodule add ../extern/Lib1 lib")
– deepblue
Dec 29 '09 at 12:25
3
damn. ok, so the absolute path worked, the relative does not... this is not mentioned anywhere (I've been reading tutorials for hours and they all use web URL's as examples). the problem with this is when someone else clones my repos, and does not have the correct dir nesting, the 'submodule init/update' wont work for them... any ideas? thanks Von, appreciate it
– deepblue
Dec 29 '09 at 12:33
will do as you suggest. question: doesnt this just move the absolute path from the super-repo (one into which we're placing the submodule) into the repo referenced by the submodule? in my case both the superrepo and the referenced repo (from inside the submodule) are in the same master dir DirName (DirName/extern/Lib1 & DirName/NewRepo_withSubmodules). So I would prefer to be able to move that master dir (DirName) around without configs inside it breaking.
– deepblue
Dec 29 '09 at 12:59
Good question, which made me revisit the.git/config
file location. See my edited answer.
– VonC
Dec 29 '09 at 13:29
1
great! so it worked. in order to use relative paths to the external submodule I had to first do the following (on a fresh - noncloned repo): "git remote add origin .." and then "git submodule add ../extern/LibName lib". thanks again Vic!
– deepblue
Dec 29 '09 at 14:14
yep it does. the ./lib folder is empty tho (in "git submodule add ../extern/Lib1 lib")
– deepblue
Dec 29 '09 at 12:25
yep it does. the ./lib folder is empty tho (in "git submodule add ../extern/Lib1 lib")
– deepblue
Dec 29 '09 at 12:25
3
3
damn. ok, so the absolute path worked, the relative does not... this is not mentioned anywhere (I've been reading tutorials for hours and they all use web URL's as examples). the problem with this is when someone else clones my repos, and does not have the correct dir nesting, the 'submodule init/update' wont work for them... any ideas? thanks Von, appreciate it
– deepblue
Dec 29 '09 at 12:33
damn. ok, so the absolute path worked, the relative does not... this is not mentioned anywhere (I've been reading tutorials for hours and they all use web URL's as examples). the problem with this is when someone else clones my repos, and does not have the correct dir nesting, the 'submodule init/update' wont work for them... any ideas? thanks Von, appreciate it
– deepblue
Dec 29 '09 at 12:33
will do as you suggest. question: doesnt this just move the absolute path from the super-repo (one into which we're placing the submodule) into the repo referenced by the submodule? in my case both the superrepo and the referenced repo (from inside the submodule) are in the same master dir DirName (DirName/extern/Lib1 & DirName/NewRepo_withSubmodules). So I would prefer to be able to move that master dir (DirName) around without configs inside it breaking.
– deepblue
Dec 29 '09 at 12:59
will do as you suggest. question: doesnt this just move the absolute path from the super-repo (one into which we're placing the submodule) into the repo referenced by the submodule? in my case both the superrepo and the referenced repo (from inside the submodule) are in the same master dir DirName (DirName/extern/Lib1 & DirName/NewRepo_withSubmodules). So I would prefer to be able to move that master dir (DirName) around without configs inside it breaking.
– deepblue
Dec 29 '09 at 12:59
Good question, which made me revisit the
.git/config
file location. See my edited answer.– VonC
Dec 29 '09 at 13:29
Good question, which made me revisit the
.git/config
file location. See my edited answer.– VonC
Dec 29 '09 at 13:29
1
1
great! so it worked. in order to use relative paths to the external submodule I had to first do the following (on a fresh - noncloned repo): "git remote add origin .." and then "git submodule add ../extern/LibName lib". thanks again Vic!
– deepblue
Dec 29 '09 at 14:14
great! so it worked. in order to use relative paths to the external submodule I had to first do the following (on a fresh - noncloned repo): "git remote add origin .." and then "git submodule add ../extern/LibName lib". thanks again Vic!
– deepblue
Dec 29 '09 at 14:14
|
show 4 more comments
I was trying the same thing, and found the following 'seems to have worked:
I have (on windows):
D:/phd/analyses
/analysis1/ #This is an existing repository
/analysis2/ #another existing repository
/analysis3.tex
/analysis4.tex
...
/analysisN.tex
analysis1.tex ... analysisN.tex
contain ideas I've not worked on yet ('stubs, say), and analysis1/
and analysis2/
are things I am working on (and hence have code, tex, ... in them). Once I get around to working on the other analyses, they will get moved to their own folders and hence their own repositories.
What I did was (in git bash in analyses):
git init
git add *.tex
git remote add self .
git submodule add self:/analysis2/.git analysis2
git submodule add self:/analysis5/.git analysis5
git commit -m "Initial commit"
This seems to have worked.
D:/phd/analyses/.git/config
looks like it should, and .gitmodules
looks like:
[submodule "analysis2"]
path = analysis2
url = self:analysis2/.git
[submodule "analysis5"]
path = analysis5
url = self:analysis5/.git
Regards,
Simon Knapp
2
Doesn't work for me (on Linux). It tries to access the computerself
over the Internet.
– Mechanical snail
Feb 28 '12 at 4:07
also does not work on darwin: …[852]$ git submodule add -b myBranch self:../relativeRepo Cloning into relativeRepo...
ssh: Could not resolve hostname self: nodename nor servname provided, or not known fatal: The remote end hung up unexpectedly` Clone of 'self:../relativeRepo' into submodule path 'relativeRepo' failed
– john.k.doe
May 4 '12 at 18:26
add a comment |
I was trying the same thing, and found the following 'seems to have worked:
I have (on windows):
D:/phd/analyses
/analysis1/ #This is an existing repository
/analysis2/ #another existing repository
/analysis3.tex
/analysis4.tex
...
/analysisN.tex
analysis1.tex ... analysisN.tex
contain ideas I've not worked on yet ('stubs, say), and analysis1/
and analysis2/
are things I am working on (and hence have code, tex, ... in them). Once I get around to working on the other analyses, they will get moved to their own folders and hence their own repositories.
What I did was (in git bash in analyses):
git init
git add *.tex
git remote add self .
git submodule add self:/analysis2/.git analysis2
git submodule add self:/analysis5/.git analysis5
git commit -m "Initial commit"
This seems to have worked.
D:/phd/analyses/.git/config
looks like it should, and .gitmodules
looks like:
[submodule "analysis2"]
path = analysis2
url = self:analysis2/.git
[submodule "analysis5"]
path = analysis5
url = self:analysis5/.git
Regards,
Simon Knapp
2
Doesn't work for me (on Linux). It tries to access the computerself
over the Internet.
– Mechanical snail
Feb 28 '12 at 4:07
also does not work on darwin: …[852]$ git submodule add -b myBranch self:../relativeRepo Cloning into relativeRepo...
ssh: Could not resolve hostname self: nodename nor servname provided, or not known fatal: The remote end hung up unexpectedly` Clone of 'self:../relativeRepo' into submodule path 'relativeRepo' failed
– john.k.doe
May 4 '12 at 18:26
add a comment |
I was trying the same thing, and found the following 'seems to have worked:
I have (on windows):
D:/phd/analyses
/analysis1/ #This is an existing repository
/analysis2/ #another existing repository
/analysis3.tex
/analysis4.tex
...
/analysisN.tex
analysis1.tex ... analysisN.tex
contain ideas I've not worked on yet ('stubs, say), and analysis1/
and analysis2/
are things I am working on (and hence have code, tex, ... in them). Once I get around to working on the other analyses, they will get moved to their own folders and hence their own repositories.
What I did was (in git bash in analyses):
git init
git add *.tex
git remote add self .
git submodule add self:/analysis2/.git analysis2
git submodule add self:/analysis5/.git analysis5
git commit -m "Initial commit"
This seems to have worked.
D:/phd/analyses/.git/config
looks like it should, and .gitmodules
looks like:
[submodule "analysis2"]
path = analysis2
url = self:analysis2/.git
[submodule "analysis5"]
path = analysis5
url = self:analysis5/.git
Regards,
Simon Knapp
I was trying the same thing, and found the following 'seems to have worked:
I have (on windows):
D:/phd/analyses
/analysis1/ #This is an existing repository
/analysis2/ #another existing repository
/analysis3.tex
/analysis4.tex
...
/analysisN.tex
analysis1.tex ... analysisN.tex
contain ideas I've not worked on yet ('stubs, say), and analysis1/
and analysis2/
are things I am working on (and hence have code, tex, ... in them). Once I get around to working on the other analyses, they will get moved to their own folders and hence their own repositories.
What I did was (in git bash in analyses):
git init
git add *.tex
git remote add self .
git submodule add self:/analysis2/.git analysis2
git submodule add self:/analysis5/.git analysis5
git commit -m "Initial commit"
This seems to have worked.
D:/phd/analyses/.git/config
looks like it should, and .gitmodules
looks like:
[submodule "analysis2"]
path = analysis2
url = self:analysis2/.git
[submodule "analysis5"]
path = analysis5
url = self:analysis5/.git
Regards,
Simon Knapp
answered Jul 14 '11 at 1:56
Simon Knapp
411
411
2
Doesn't work for me (on Linux). It tries to access the computerself
over the Internet.
– Mechanical snail
Feb 28 '12 at 4:07
also does not work on darwin: …[852]$ git submodule add -b myBranch self:../relativeRepo Cloning into relativeRepo...
ssh: Could not resolve hostname self: nodename nor servname provided, or not known fatal: The remote end hung up unexpectedly` Clone of 'self:../relativeRepo' into submodule path 'relativeRepo' failed
– john.k.doe
May 4 '12 at 18:26
add a comment |
2
Doesn't work for me (on Linux). It tries to access the computerself
over the Internet.
– Mechanical snail
Feb 28 '12 at 4:07
also does not work on darwin: …[852]$ git submodule add -b myBranch self:../relativeRepo Cloning into relativeRepo...
ssh: Could not resolve hostname self: nodename nor servname provided, or not known fatal: The remote end hung up unexpectedly` Clone of 'self:../relativeRepo' into submodule path 'relativeRepo' failed
– john.k.doe
May 4 '12 at 18:26
2
2
Doesn't work for me (on Linux). It tries to access the computer
self
over the Internet.– Mechanical snail
Feb 28 '12 at 4:07
Doesn't work for me (on Linux). It tries to access the computer
self
over the Internet.– Mechanical snail
Feb 28 '12 at 4:07
also does not work on darwin: …
[852]$ git submodule add -b myBranch self:../relativeRepo Cloning into relativeRepo...
ssh: Could not resolve hostname self: nodename nor servname provided, or not known fatal: The remote end hung up unexpectedly` Clone of 'self:../relativeRepo' into submodule path 'relativeRepo' failed– john.k.doe
May 4 '12 at 18:26
also does not work on darwin: …
[852]$ git submodule add -b myBranch self:../relativeRepo Cloning into relativeRepo...
ssh: Could not resolve hostname self: nodename nor servname provided, or not known fatal: The remote end hung up unexpectedly` Clone of 'self:../relativeRepo' into submodule path 'relativeRepo' failed– john.k.doe
May 4 '12 at 18:26
add a comment |
(I've summarized just the solution here. Credit goes to VonC.)
In the containing repository (say containing.git/
), git
interprets relative paths as relative to the origin
remote, which is not defined. We want it to be relative to the containing.git/
directory, so run
git remote add origin ..
(Not sure why it's ..
rather than .
.)
Now you can add the sub-module:
git submodule add ../extern/Lib1 lib
This didn't work for me - it still tried to look up../extern/Lib1
in the local path. I had to dogit remote rename myrem origin
, thengit submodule add ../extern/Lib1 lib
, thengit remote rename origin myrem
andgit submodule foreach git remote rename origin myrem
– M.M
Apr 21 '16 at 8:42
add a comment |
(I've summarized just the solution here. Credit goes to VonC.)
In the containing repository (say containing.git/
), git
interprets relative paths as relative to the origin
remote, which is not defined. We want it to be relative to the containing.git/
directory, so run
git remote add origin ..
(Not sure why it's ..
rather than .
.)
Now you can add the sub-module:
git submodule add ../extern/Lib1 lib
This didn't work for me - it still tried to look up../extern/Lib1
in the local path. I had to dogit remote rename myrem origin
, thengit submodule add ../extern/Lib1 lib
, thengit remote rename origin myrem
andgit submodule foreach git remote rename origin myrem
– M.M
Apr 21 '16 at 8:42
add a comment |
(I've summarized just the solution here. Credit goes to VonC.)
In the containing repository (say containing.git/
), git
interprets relative paths as relative to the origin
remote, which is not defined. We want it to be relative to the containing.git/
directory, so run
git remote add origin ..
(Not sure why it's ..
rather than .
.)
Now you can add the sub-module:
git submodule add ../extern/Lib1 lib
(I've summarized just the solution here. Credit goes to VonC.)
In the containing repository (say containing.git/
), git
interprets relative paths as relative to the origin
remote, which is not defined. We want it to be relative to the containing.git/
directory, so run
git remote add origin ..
(Not sure why it's ..
rather than .
.)
Now you can add the sub-module:
git submodule add ../extern/Lib1 lib
answered Feb 28 '12 at 4:42
community wiki
Mechanical snail
This didn't work for me - it still tried to look up../extern/Lib1
in the local path. I had to dogit remote rename myrem origin
, thengit submodule add ../extern/Lib1 lib
, thengit remote rename origin myrem
andgit submodule foreach git remote rename origin myrem
– M.M
Apr 21 '16 at 8:42
add a comment |
This didn't work for me - it still tried to look up../extern/Lib1
in the local path. I had to dogit remote rename myrem origin
, thengit submodule add ../extern/Lib1 lib
, thengit remote rename origin myrem
andgit submodule foreach git remote rename origin myrem
– M.M
Apr 21 '16 at 8:42
This didn't work for me - it still tried to look up
../extern/Lib1
in the local path. I had to do git remote rename myrem origin
, then git submodule add ../extern/Lib1 lib
, then git remote rename origin myrem
and git submodule foreach git remote rename origin myrem
– M.M
Apr 21 '16 at 8:42
This didn't work for me - it still tried to look up
../extern/Lib1
in the local path. I had to do git remote rename myrem origin
, then git submodule add ../extern/Lib1 lib
, then git remote rename origin myrem
and git submodule foreach git remote rename origin myrem
– M.M
Apr 21 '16 at 8:42
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f1974181%2fcant-add-git-submodule-when-specified-as-a-relative-path%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Just completed my answer with additional suggestions
– VonC
Dec 29 '09 at 12:28
I think the absolute path works here only because your
extern/Lib1
Git repo ... does not have a "remote origin does not have a url defined in.git/config
" ;). Some investigation in that .git/config is in order.– VonC
Dec 29 '09 at 12:42
not sure what you mean. I just looked at extern/Lib1's .git/config and all it has is the [core] section: repositoryformatversion=0,filemode=true,bare=false,legalrefupdates=true
– deepblue
Dec 29 '09 at 12:47
Just added an example about where exactly that "remote origin" should be defined. See my edited answer.
– VonC
Dec 29 '09 at 12:47
Your last comment made me re-read the git submodule man page. I have edited my answer for a more exact location of the relevant
.git/config
file.– VonC
Dec 29 '09 at 13:30