Git submodule add: “a git directory is found locally” issue
I'm actually trying to learn how to use git, including the "git submodule" subcommands.
I already set up a server on which I can host, push and pull git repositories by using ssh.
I created on this server a main git repository "Travail" in wich I would like to put all my projects as submodules.
In my Travail repository, I already added a project of mine as a submodule at tools/libft
:
I'm able to develop this submodule, to push and to pull it.
But when I try to add an other submodule (named fdf, from fdf.git on my server), I get the following issue :
git submodule add ssh://XXX.XXX.XXX.XXX:XXXXX/opt/git/fdf.git projets/fdf
A git directory for 'projets/fdf' is found locally with remote(s):
origin ssh://git@XXX.XXX.XXX.XXX:XXXXX/opt/git/fdf.git
If you want to reuse this local git directory instead of cloning again from
ssh://XXX.XXX.XXX.XXX:XXXXX/opt/git/fdf.git
use the '--force' option. If the local git directory is not the correct repo
or you are unsure what this means choose another name with the '--name' option.
There is actually no subdirectory in projets/
I read on an other thread that I should use git submodule sync or edit the .gitmodules file in which the URL to my submodule's origin repository could have changed.
But my .gitmodules file only contains the information about my first submodule (tools/libft), not about projets/fdf :
[submodule "tools/libft"]
path = tools/libft
url = ssh://git@XXX.XXX.XXX.XXX:XXXXX/opt/git/libft.git
As a French student I could have missed something in the english documentation I have, but I searched and I really don't understand why I get this issue.
I would be glad if I would get a solution but just an explanation would be helpful too.
git git-submodules
|
show 3 more comments
I'm actually trying to learn how to use git, including the "git submodule" subcommands.
I already set up a server on which I can host, push and pull git repositories by using ssh.
I created on this server a main git repository "Travail" in wich I would like to put all my projects as submodules.
In my Travail repository, I already added a project of mine as a submodule at tools/libft
:
I'm able to develop this submodule, to push and to pull it.
But when I try to add an other submodule (named fdf, from fdf.git on my server), I get the following issue :
git submodule add ssh://XXX.XXX.XXX.XXX:XXXXX/opt/git/fdf.git projets/fdf
A git directory for 'projets/fdf' is found locally with remote(s):
origin ssh://git@XXX.XXX.XXX.XXX:XXXXX/opt/git/fdf.git
If you want to reuse this local git directory instead of cloning again from
ssh://XXX.XXX.XXX.XXX:XXXXX/opt/git/fdf.git
use the '--force' option. If the local git directory is not the correct repo
or you are unsure what this means choose another name with the '--name' option.
There is actually no subdirectory in projets/
I read on an other thread that I should use git submodule sync or edit the .gitmodules file in which the URL to my submodule's origin repository could have changed.
But my .gitmodules file only contains the information about my first submodule (tools/libft), not about projets/fdf :
[submodule "tools/libft"]
path = tools/libft
url = ssh://git@XXX.XXX.XXX.XXX:XXXXX/opt/git/libft.git
As a French student I could have missed something in the english documentation I have, but I searched and I really don't understand why I get this issue.
I would be glad if I would get a solution but just an explanation would be helpful too.
git git-submodules
A small correction: it's 'repository', not 'depository'. Not really an answer, but if the projects are independent of each other it would be better for each project to have its own repo instead of submodules.
– jcm
Jan 5 '14 at 2:40
Thank you, I corrected. I know but I would like to gather all my work in the same repo but as separate projects. It is a choice to keep my whole work updated when I go from home to my school and vice versa (and to learn how to use these tools, I'm curious ;) )
– vmonteco
Jan 5 '14 at 2:49
Well, curiosity is always a good reason! :) That is strange. Are you sure you haven't added the submodule before?
– jcm
Jan 5 '14 at 2:54
Not in Travail/, and I have no problème to clone fdf.git in ~/ . In Travail/ I find no traces of fdf. just libft :/
– vmonteco
Jan 5 '14 at 3:11
4
Oh wait, I looked in/Travail/.git/modules/projets/
and I found afdf
directory. This seems to not be in the working tree but in older commits. Could it generate the issue?
– vmonteco
Jan 5 '14 at 3:15
|
show 3 more comments
I'm actually trying to learn how to use git, including the "git submodule" subcommands.
I already set up a server on which I can host, push and pull git repositories by using ssh.
I created on this server a main git repository "Travail" in wich I would like to put all my projects as submodules.
In my Travail repository, I already added a project of mine as a submodule at tools/libft
:
I'm able to develop this submodule, to push and to pull it.
But when I try to add an other submodule (named fdf, from fdf.git on my server), I get the following issue :
git submodule add ssh://XXX.XXX.XXX.XXX:XXXXX/opt/git/fdf.git projets/fdf
A git directory for 'projets/fdf' is found locally with remote(s):
origin ssh://git@XXX.XXX.XXX.XXX:XXXXX/opt/git/fdf.git
If you want to reuse this local git directory instead of cloning again from
ssh://XXX.XXX.XXX.XXX:XXXXX/opt/git/fdf.git
use the '--force' option. If the local git directory is not the correct repo
or you are unsure what this means choose another name with the '--name' option.
There is actually no subdirectory in projets/
I read on an other thread that I should use git submodule sync or edit the .gitmodules file in which the URL to my submodule's origin repository could have changed.
But my .gitmodules file only contains the information about my first submodule (tools/libft), not about projets/fdf :
[submodule "tools/libft"]
path = tools/libft
url = ssh://git@XXX.XXX.XXX.XXX:XXXXX/opt/git/libft.git
As a French student I could have missed something in the english documentation I have, but I searched and I really don't understand why I get this issue.
I would be glad if I would get a solution but just an explanation would be helpful too.
git git-submodules
I'm actually trying to learn how to use git, including the "git submodule" subcommands.
I already set up a server on which I can host, push and pull git repositories by using ssh.
I created on this server a main git repository "Travail" in wich I would like to put all my projects as submodules.
In my Travail repository, I already added a project of mine as a submodule at tools/libft
:
I'm able to develop this submodule, to push and to pull it.
But when I try to add an other submodule (named fdf, from fdf.git on my server), I get the following issue :
git submodule add ssh://XXX.XXX.XXX.XXX:XXXXX/opt/git/fdf.git projets/fdf
A git directory for 'projets/fdf' is found locally with remote(s):
origin ssh://git@XXX.XXX.XXX.XXX:XXXXX/opt/git/fdf.git
If you want to reuse this local git directory instead of cloning again from
ssh://XXX.XXX.XXX.XXX:XXXXX/opt/git/fdf.git
use the '--force' option. If the local git directory is not the correct repo
or you are unsure what this means choose another name with the '--name' option.
There is actually no subdirectory in projets/
I read on an other thread that I should use git submodule sync or edit the .gitmodules file in which the URL to my submodule's origin repository could have changed.
But my .gitmodules file only contains the information about my first submodule (tools/libft), not about projets/fdf :
[submodule "tools/libft"]
path = tools/libft
url = ssh://git@XXX.XXX.XXX.XXX:XXXXX/opt/git/libft.git
As a French student I could have missed something in the english documentation I have, but I searched and I really don't understand why I get this issue.
I would be glad if I would get a solution but just an explanation would be helpful too.
git git-submodules
git git-submodules
edited Nov 27 '17 at 5:33
Tom Jowitt
3,52293754
3,52293754
asked Jan 5 '14 at 2:32
vmontecovmonteco
4,86892854
4,86892854
A small correction: it's 'repository', not 'depository'. Not really an answer, but if the projects are independent of each other it would be better for each project to have its own repo instead of submodules.
– jcm
Jan 5 '14 at 2:40
Thank you, I corrected. I know but I would like to gather all my work in the same repo but as separate projects. It is a choice to keep my whole work updated when I go from home to my school and vice versa (and to learn how to use these tools, I'm curious ;) )
– vmonteco
Jan 5 '14 at 2:49
Well, curiosity is always a good reason! :) That is strange. Are you sure you haven't added the submodule before?
– jcm
Jan 5 '14 at 2:54
Not in Travail/, and I have no problème to clone fdf.git in ~/ . In Travail/ I find no traces of fdf. just libft :/
– vmonteco
Jan 5 '14 at 3:11
4
Oh wait, I looked in/Travail/.git/modules/projets/
and I found afdf
directory. This seems to not be in the working tree but in older commits. Could it generate the issue?
– vmonteco
Jan 5 '14 at 3:15
|
show 3 more comments
A small correction: it's 'repository', not 'depository'. Not really an answer, but if the projects are independent of each other it would be better for each project to have its own repo instead of submodules.
– jcm
Jan 5 '14 at 2:40
Thank you, I corrected. I know but I would like to gather all my work in the same repo but as separate projects. It is a choice to keep my whole work updated when I go from home to my school and vice versa (and to learn how to use these tools, I'm curious ;) )
– vmonteco
Jan 5 '14 at 2:49
Well, curiosity is always a good reason! :) That is strange. Are you sure you haven't added the submodule before?
– jcm
Jan 5 '14 at 2:54
Not in Travail/, and I have no problème to clone fdf.git in ~/ . In Travail/ I find no traces of fdf. just libft :/
– vmonteco
Jan 5 '14 at 3:11
4
Oh wait, I looked in/Travail/.git/modules/projets/
and I found afdf
directory. This seems to not be in the working tree but in older commits. Could it generate the issue?
– vmonteco
Jan 5 '14 at 3:15
A small correction: it's 'repository', not 'depository'. Not really an answer, but if the projects are independent of each other it would be better for each project to have its own repo instead of submodules.
– jcm
Jan 5 '14 at 2:40
A small correction: it's 'repository', not 'depository'. Not really an answer, but if the projects are independent of each other it would be better for each project to have its own repo instead of submodules.
– jcm
Jan 5 '14 at 2:40
Thank you, I corrected. I know but I would like to gather all my work in the same repo but as separate projects. It is a choice to keep my whole work updated when I go from home to my school and vice versa (and to learn how to use these tools, I'm curious ;) )
– vmonteco
Jan 5 '14 at 2:49
Thank you, I corrected. I know but I would like to gather all my work in the same repo but as separate projects. It is a choice to keep my whole work updated when I go from home to my school and vice versa (and to learn how to use these tools, I'm curious ;) )
– vmonteco
Jan 5 '14 at 2:49
Well, curiosity is always a good reason! :) That is strange. Are you sure you haven't added the submodule before?
– jcm
Jan 5 '14 at 2:54
Well, curiosity is always a good reason! :) That is strange. Are you sure you haven't added the submodule before?
– jcm
Jan 5 '14 at 2:54
Not in Travail/, and I have no problème to clone fdf.git in ~/ . In Travail/ I find no traces of fdf. just libft :/
– vmonteco
Jan 5 '14 at 3:11
Not in Travail/, and I have no problème to clone fdf.git in ~/ . In Travail/ I find no traces of fdf. just libft :/
– vmonteco
Jan 5 '14 at 3:11
4
4
Oh wait, I looked in
/Travail/.git/modules/projets/
and I found a fdf
directory. This seems to not be in the working tree but in older commits. Could it generate the issue?– vmonteco
Jan 5 '14 at 3:15
Oh wait, I looked in
/Travail/.git/modules/projets/
and I found a fdf
directory. This seems to not be in the working tree but in older commits. Could it generate the issue?– vmonteco
Jan 5 '14 at 3:15
|
show 3 more comments
6 Answers
6
active
oldest
votes
I came to this SO post trying to add a submodule with the same path as a submodule that I recently deleted.
This is what ultimately worked for me (this article helped out a lot):
If you haven't already run git rm --cached path_to_submodule
(no trailing slash) as well as rm -rf path_to_submodule
, do that!
Then:
Delete the relevant lines from the
.gitmodules
file. e.g. delete these:
[submodule "path_to_submodule"]
path = path_to_submodule
url = https://github.com/path_to_submodule
Delete the relevant section from .git/config. e.g. delete these:
[submodule "path_to_submodule"]
url = https://github.com/path_to_submodule
rm -rf .git/modules/path_to_submodule
Then, you can finally:
git submodule add https://github.com/path_to_submodule
16
This was really helpful, as I could find nothing else that worked. The key difference from other suggestions was your step #3. Thanks!
– Alex
May 14 '16 at 17:36
@Alex glad it was helpful!
– jbmilgrom
May 16 '16 at 17:04
7
Steps 2 & 3 were needed for me.
– U007D
Aug 17 '16 at 0:01
7
Step 3 was needed for me but, why does the submodule exist there too?
– Crt
Nov 7 '16 at 19:40
1
For me, I skipped steps 1 & 2 (which had the correct settings in it already) and step 3 fixed it for me. (I had already done the initial step ofgit rm
andrm -rf
steps.)
– Rock Lee
Dec 28 '16 at 22:05
|
show 2 more comments
i tried jbmilgrom's solution, specifically i tried git rm --cache
and that didn't work for me either as the directory/submodule wasn't there. What worked for me was:
rm -rf .git/modules/blah
git submodule add git://path.to.new
I did this after trying --force
within the git submodule
commands and rm
all the other directories, pushes to master etc... the directory didn't exist and there was no reason for the cache. Turns out in .git/modules
that is where this error was lying.
add a comment |
You may have deleted your 'projets/fdf'
from disk, but your Git repository still has it. Use git rm -rf projets/fdf
to remove it from Git, then commit the changes. After that you'll be able to add this folder as a submodule.
It worked :) Thank you. I think I actually made this mistake.
– vmonteco
Jan 5 '14 at 4:21
20
I get told the directory doesn't exist when I do this. Seems it both exists and doesn't :/
– Nathan Hornby
Feb 6 '15 at 14:12
38
@tom-mcfarlin In the end, Imanually removed lines from .gitmodule and a folder from .git/modules, then it let me add a new submodule. Maybe there's better way to do this, but I was running out of time. If you gonna go this way, I recommend you make a good backup and please don't blame me, if it goes wrong for you. Good luck.
– sparklos
Mar 30 '15 at 10:43
5
Thank you, I found on another post to remove the folder from .git/modules and that worked for me. Makes sense as that's what the error said was the conflict... I just was unaware of that folder
– Tom McFarlin
Mar 30 '15 at 15:10
9
@NathanHornby @Sparklos @TomMcFarlin -- In more recent versions of git, you will find that git-submodule adds a directory in .git folder. For example, if you are in directory/tmp/repo
, then rungit submodule add ../otherrepo.git
, then you will see that/tmp/repo/.git/modules/otherrepo
folder exists. That is what the problem was for me. I manually deleted that folder from .git, and everything worked.
– Alexander Bird
Mar 4 '16 at 20:40
|
show 7 more comments
If you already deleted the submodule directory, like I did, follow the rest of jbmilgrom's instructions. The key is rm -rf .git/modules/path_to_submodule
but go ahead and backup your whole parent repo directory first.
If you only had one submodule just delete .gitmodules
add a comment |
These two commands works for me.
rm path/to/submodule -rf
rm .git/modules/path/to/module -rf
This. It seems there are two ways for submodules to be created. In one of them, the subfolder will only have a single .git file that simply points to a directory in the superproject, starting with.git/modules/
. In there is a folder that stores the repository for the submodule. Deleting that repository fixed the issue for me, while the accepted answer didn't.
– William Randokun
2 days ago
add a comment |
I tried these answers and they didn't work for me. The only thing that worked for me was deleting my parent repo and pulling it down again. Hope this helps somebody
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%2f20929336%2fgit-submodule-add-a-git-directory-is-found-locally-issue%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
6 Answers
6
active
oldest
votes
6 Answers
6
active
oldest
votes
active
oldest
votes
active
oldest
votes
I came to this SO post trying to add a submodule with the same path as a submodule that I recently deleted.
This is what ultimately worked for me (this article helped out a lot):
If you haven't already run git rm --cached path_to_submodule
(no trailing slash) as well as rm -rf path_to_submodule
, do that!
Then:
Delete the relevant lines from the
.gitmodules
file. e.g. delete these:
[submodule "path_to_submodule"]
path = path_to_submodule
url = https://github.com/path_to_submodule
Delete the relevant section from .git/config. e.g. delete these:
[submodule "path_to_submodule"]
url = https://github.com/path_to_submodule
rm -rf .git/modules/path_to_submodule
Then, you can finally:
git submodule add https://github.com/path_to_submodule
16
This was really helpful, as I could find nothing else that worked. The key difference from other suggestions was your step #3. Thanks!
– Alex
May 14 '16 at 17:36
@Alex glad it was helpful!
– jbmilgrom
May 16 '16 at 17:04
7
Steps 2 & 3 were needed for me.
– U007D
Aug 17 '16 at 0:01
7
Step 3 was needed for me but, why does the submodule exist there too?
– Crt
Nov 7 '16 at 19:40
1
For me, I skipped steps 1 & 2 (which had the correct settings in it already) and step 3 fixed it for me. (I had already done the initial step ofgit rm
andrm -rf
steps.)
– Rock Lee
Dec 28 '16 at 22:05
|
show 2 more comments
I came to this SO post trying to add a submodule with the same path as a submodule that I recently deleted.
This is what ultimately worked for me (this article helped out a lot):
If you haven't already run git rm --cached path_to_submodule
(no trailing slash) as well as rm -rf path_to_submodule
, do that!
Then:
Delete the relevant lines from the
.gitmodules
file. e.g. delete these:
[submodule "path_to_submodule"]
path = path_to_submodule
url = https://github.com/path_to_submodule
Delete the relevant section from .git/config. e.g. delete these:
[submodule "path_to_submodule"]
url = https://github.com/path_to_submodule
rm -rf .git/modules/path_to_submodule
Then, you can finally:
git submodule add https://github.com/path_to_submodule
16
This was really helpful, as I could find nothing else that worked. The key difference from other suggestions was your step #3. Thanks!
– Alex
May 14 '16 at 17:36
@Alex glad it was helpful!
– jbmilgrom
May 16 '16 at 17:04
7
Steps 2 & 3 were needed for me.
– U007D
Aug 17 '16 at 0:01
7
Step 3 was needed for me but, why does the submodule exist there too?
– Crt
Nov 7 '16 at 19:40
1
For me, I skipped steps 1 & 2 (which had the correct settings in it already) and step 3 fixed it for me. (I had already done the initial step ofgit rm
andrm -rf
steps.)
– Rock Lee
Dec 28 '16 at 22:05
|
show 2 more comments
I came to this SO post trying to add a submodule with the same path as a submodule that I recently deleted.
This is what ultimately worked for me (this article helped out a lot):
If you haven't already run git rm --cached path_to_submodule
(no trailing slash) as well as rm -rf path_to_submodule
, do that!
Then:
Delete the relevant lines from the
.gitmodules
file. e.g. delete these:
[submodule "path_to_submodule"]
path = path_to_submodule
url = https://github.com/path_to_submodule
Delete the relevant section from .git/config. e.g. delete these:
[submodule "path_to_submodule"]
url = https://github.com/path_to_submodule
rm -rf .git/modules/path_to_submodule
Then, you can finally:
git submodule add https://github.com/path_to_submodule
I came to this SO post trying to add a submodule with the same path as a submodule that I recently deleted.
This is what ultimately worked for me (this article helped out a lot):
If you haven't already run git rm --cached path_to_submodule
(no trailing slash) as well as rm -rf path_to_submodule
, do that!
Then:
Delete the relevant lines from the
.gitmodules
file. e.g. delete these:
[submodule "path_to_submodule"]
path = path_to_submodule
url = https://github.com/path_to_submodule
Delete the relevant section from .git/config. e.g. delete these:
[submodule "path_to_submodule"]
url = https://github.com/path_to_submodule
rm -rf .git/modules/path_to_submodule
Then, you can finally:
git submodule add https://github.com/path_to_submodule
edited Jan 3 at 1:50
answered Mar 3 '16 at 16:48
jbmilgromjbmilgrom
4,27321619
4,27321619
16
This was really helpful, as I could find nothing else that worked. The key difference from other suggestions was your step #3. Thanks!
– Alex
May 14 '16 at 17:36
@Alex glad it was helpful!
– jbmilgrom
May 16 '16 at 17:04
7
Steps 2 & 3 were needed for me.
– U007D
Aug 17 '16 at 0:01
7
Step 3 was needed for me but, why does the submodule exist there too?
– Crt
Nov 7 '16 at 19:40
1
For me, I skipped steps 1 & 2 (which had the correct settings in it already) and step 3 fixed it for me. (I had already done the initial step ofgit rm
andrm -rf
steps.)
– Rock Lee
Dec 28 '16 at 22:05
|
show 2 more comments
16
This was really helpful, as I could find nothing else that worked. The key difference from other suggestions was your step #3. Thanks!
– Alex
May 14 '16 at 17:36
@Alex glad it was helpful!
– jbmilgrom
May 16 '16 at 17:04
7
Steps 2 & 3 were needed for me.
– U007D
Aug 17 '16 at 0:01
7
Step 3 was needed for me but, why does the submodule exist there too?
– Crt
Nov 7 '16 at 19:40
1
For me, I skipped steps 1 & 2 (which had the correct settings in it already) and step 3 fixed it for me. (I had already done the initial step ofgit rm
andrm -rf
steps.)
– Rock Lee
Dec 28 '16 at 22:05
16
16
This was really helpful, as I could find nothing else that worked. The key difference from other suggestions was your step #3. Thanks!
– Alex
May 14 '16 at 17:36
This was really helpful, as I could find nothing else that worked. The key difference from other suggestions was your step #3. Thanks!
– Alex
May 14 '16 at 17:36
@Alex glad it was helpful!
– jbmilgrom
May 16 '16 at 17:04
@Alex glad it was helpful!
– jbmilgrom
May 16 '16 at 17:04
7
7
Steps 2 & 3 were needed for me.
– U007D
Aug 17 '16 at 0:01
Steps 2 & 3 were needed for me.
– U007D
Aug 17 '16 at 0:01
7
7
Step 3 was needed for me but, why does the submodule exist there too?
– Crt
Nov 7 '16 at 19:40
Step 3 was needed for me but, why does the submodule exist there too?
– Crt
Nov 7 '16 at 19:40
1
1
For me, I skipped steps 1 & 2 (which had the correct settings in it already) and step 3 fixed it for me. (I had already done the initial step of
git rm
and rm -rf
steps.)– Rock Lee
Dec 28 '16 at 22:05
For me, I skipped steps 1 & 2 (which had the correct settings in it already) and step 3 fixed it for me. (I had already done the initial step of
git rm
and rm -rf
steps.)– Rock Lee
Dec 28 '16 at 22:05
|
show 2 more comments
i tried jbmilgrom's solution, specifically i tried git rm --cache
and that didn't work for me either as the directory/submodule wasn't there. What worked for me was:
rm -rf .git/modules/blah
git submodule add git://path.to.new
I did this after trying --force
within the git submodule
commands and rm
all the other directories, pushes to master etc... the directory didn't exist and there was no reason for the cache. Turns out in .git/modules
that is where this error was lying.
add a comment |
i tried jbmilgrom's solution, specifically i tried git rm --cache
and that didn't work for me either as the directory/submodule wasn't there. What worked for me was:
rm -rf .git/modules/blah
git submodule add git://path.to.new
I did this after trying --force
within the git submodule
commands and rm
all the other directories, pushes to master etc... the directory didn't exist and there was no reason for the cache. Turns out in .git/modules
that is where this error was lying.
add a comment |
i tried jbmilgrom's solution, specifically i tried git rm --cache
and that didn't work for me either as the directory/submodule wasn't there. What worked for me was:
rm -rf .git/modules/blah
git submodule add git://path.to.new
I did this after trying --force
within the git submodule
commands and rm
all the other directories, pushes to master etc... the directory didn't exist and there was no reason for the cache. Turns out in .git/modules
that is where this error was lying.
i tried jbmilgrom's solution, specifically i tried git rm --cache
and that didn't work for me either as the directory/submodule wasn't there. What worked for me was:
rm -rf .git/modules/blah
git submodule add git://path.to.new
I did this after trying --force
within the git submodule
commands and rm
all the other directories, pushes to master etc... the directory didn't exist and there was no reason for the cache. Turns out in .git/modules
that is where this error was lying.
answered Jul 17 '16 at 11:06
pjammerpjammer
8,17344054
8,17344054
add a comment |
add a comment |
You may have deleted your 'projets/fdf'
from disk, but your Git repository still has it. Use git rm -rf projets/fdf
to remove it from Git, then commit the changes. After that you'll be able to add this folder as a submodule.
It worked :) Thank you. I think I actually made this mistake.
– vmonteco
Jan 5 '14 at 4:21
20
I get told the directory doesn't exist when I do this. Seems it both exists and doesn't :/
– Nathan Hornby
Feb 6 '15 at 14:12
38
@tom-mcfarlin In the end, Imanually removed lines from .gitmodule and a folder from .git/modules, then it let me add a new submodule. Maybe there's better way to do this, but I was running out of time. If you gonna go this way, I recommend you make a good backup and please don't blame me, if it goes wrong for you. Good luck.
– sparklos
Mar 30 '15 at 10:43
5
Thank you, I found on another post to remove the folder from .git/modules and that worked for me. Makes sense as that's what the error said was the conflict... I just was unaware of that folder
– Tom McFarlin
Mar 30 '15 at 15:10
9
@NathanHornby @Sparklos @TomMcFarlin -- In more recent versions of git, you will find that git-submodule adds a directory in .git folder. For example, if you are in directory/tmp/repo
, then rungit submodule add ../otherrepo.git
, then you will see that/tmp/repo/.git/modules/otherrepo
folder exists. That is what the problem was for me. I manually deleted that folder from .git, and everything worked.
– Alexander Bird
Mar 4 '16 at 20:40
|
show 7 more comments
You may have deleted your 'projets/fdf'
from disk, but your Git repository still has it. Use git rm -rf projets/fdf
to remove it from Git, then commit the changes. After that you'll be able to add this folder as a submodule.
It worked :) Thank you. I think I actually made this mistake.
– vmonteco
Jan 5 '14 at 4:21
20
I get told the directory doesn't exist when I do this. Seems it both exists and doesn't :/
– Nathan Hornby
Feb 6 '15 at 14:12
38
@tom-mcfarlin In the end, Imanually removed lines from .gitmodule and a folder from .git/modules, then it let me add a new submodule. Maybe there's better way to do this, but I was running out of time. If you gonna go this way, I recommend you make a good backup and please don't blame me, if it goes wrong for you. Good luck.
– sparklos
Mar 30 '15 at 10:43
5
Thank you, I found on another post to remove the folder from .git/modules and that worked for me. Makes sense as that's what the error said was the conflict... I just was unaware of that folder
– Tom McFarlin
Mar 30 '15 at 15:10
9
@NathanHornby @Sparklos @TomMcFarlin -- In more recent versions of git, you will find that git-submodule adds a directory in .git folder. For example, if you are in directory/tmp/repo
, then rungit submodule add ../otherrepo.git
, then you will see that/tmp/repo/.git/modules/otherrepo
folder exists. That is what the problem was for me. I manually deleted that folder from .git, and everything worked.
– Alexander Bird
Mar 4 '16 at 20:40
|
show 7 more comments
You may have deleted your 'projets/fdf'
from disk, but your Git repository still has it. Use git rm -rf projets/fdf
to remove it from Git, then commit the changes. After that you'll be able to add this folder as a submodule.
You may have deleted your 'projets/fdf'
from disk, but your Git repository still has it. Use git rm -rf projets/fdf
to remove it from Git, then commit the changes. After that you'll be able to add this folder as a submodule.
answered Jan 5 '14 at 4:06
bredikhinbredikhin
7,21233142
7,21233142
It worked :) Thank you. I think I actually made this mistake.
– vmonteco
Jan 5 '14 at 4:21
20
I get told the directory doesn't exist when I do this. Seems it both exists and doesn't :/
– Nathan Hornby
Feb 6 '15 at 14:12
38
@tom-mcfarlin In the end, Imanually removed lines from .gitmodule and a folder from .git/modules, then it let me add a new submodule. Maybe there's better way to do this, but I was running out of time. If you gonna go this way, I recommend you make a good backup and please don't blame me, if it goes wrong for you. Good luck.
– sparklos
Mar 30 '15 at 10:43
5
Thank you, I found on another post to remove the folder from .git/modules and that worked for me. Makes sense as that's what the error said was the conflict... I just was unaware of that folder
– Tom McFarlin
Mar 30 '15 at 15:10
9
@NathanHornby @Sparklos @TomMcFarlin -- In more recent versions of git, you will find that git-submodule adds a directory in .git folder. For example, if you are in directory/tmp/repo
, then rungit submodule add ../otherrepo.git
, then you will see that/tmp/repo/.git/modules/otherrepo
folder exists. That is what the problem was for me. I manually deleted that folder from .git, and everything worked.
– Alexander Bird
Mar 4 '16 at 20:40
|
show 7 more comments
It worked :) Thank you. I think I actually made this mistake.
– vmonteco
Jan 5 '14 at 4:21
20
I get told the directory doesn't exist when I do this. Seems it both exists and doesn't :/
– Nathan Hornby
Feb 6 '15 at 14:12
38
@tom-mcfarlin In the end, Imanually removed lines from .gitmodule and a folder from .git/modules, then it let me add a new submodule. Maybe there's better way to do this, but I was running out of time. If you gonna go this way, I recommend you make a good backup and please don't blame me, if it goes wrong for you. Good luck.
– sparklos
Mar 30 '15 at 10:43
5
Thank you, I found on another post to remove the folder from .git/modules and that worked for me. Makes sense as that's what the error said was the conflict... I just was unaware of that folder
– Tom McFarlin
Mar 30 '15 at 15:10
9
@NathanHornby @Sparklos @TomMcFarlin -- In more recent versions of git, you will find that git-submodule adds a directory in .git folder. For example, if you are in directory/tmp/repo
, then rungit submodule add ../otherrepo.git
, then you will see that/tmp/repo/.git/modules/otherrepo
folder exists. That is what the problem was for me. I manually deleted that folder from .git, and everything worked.
– Alexander Bird
Mar 4 '16 at 20:40
It worked :) Thank you. I think I actually made this mistake.
– vmonteco
Jan 5 '14 at 4:21
It worked :) Thank you. I think I actually made this mistake.
– vmonteco
Jan 5 '14 at 4:21
20
20
I get told the directory doesn't exist when I do this. Seems it both exists and doesn't :/
– Nathan Hornby
Feb 6 '15 at 14:12
I get told the directory doesn't exist when I do this. Seems it both exists and doesn't :/
– Nathan Hornby
Feb 6 '15 at 14:12
38
38
@tom-mcfarlin In the end, Imanually removed lines from .gitmodule and a folder from .git/modules, then it let me add a new submodule. Maybe there's better way to do this, but I was running out of time. If you gonna go this way, I recommend you make a good backup and please don't blame me, if it goes wrong for you. Good luck.
– sparklos
Mar 30 '15 at 10:43
@tom-mcfarlin In the end, Imanually removed lines from .gitmodule and a folder from .git/modules, then it let me add a new submodule. Maybe there's better way to do this, but I was running out of time. If you gonna go this way, I recommend you make a good backup and please don't blame me, if it goes wrong for you. Good luck.
– sparklos
Mar 30 '15 at 10:43
5
5
Thank you, I found on another post to remove the folder from .git/modules and that worked for me. Makes sense as that's what the error said was the conflict... I just was unaware of that folder
– Tom McFarlin
Mar 30 '15 at 15:10
Thank you, I found on another post to remove the folder from .git/modules and that worked for me. Makes sense as that's what the error said was the conflict... I just was unaware of that folder
– Tom McFarlin
Mar 30 '15 at 15:10
9
9
@NathanHornby @Sparklos @TomMcFarlin -- In more recent versions of git, you will find that git-submodule adds a directory in .git folder. For example, if you are in directory
/tmp/repo
, then run git submodule add ../otherrepo.git
, then you will see that /tmp/repo/.git/modules/otherrepo
folder exists. That is what the problem was for me. I manually deleted that folder from .git, and everything worked.– Alexander Bird
Mar 4 '16 at 20:40
@NathanHornby @Sparklos @TomMcFarlin -- In more recent versions of git, you will find that git-submodule adds a directory in .git folder. For example, if you are in directory
/tmp/repo
, then run git submodule add ../otherrepo.git
, then you will see that /tmp/repo/.git/modules/otherrepo
folder exists. That is what the problem was for me. I manually deleted that folder from .git, and everything worked.– Alexander Bird
Mar 4 '16 at 20:40
|
show 7 more comments
If you already deleted the submodule directory, like I did, follow the rest of jbmilgrom's instructions. The key is rm -rf .git/modules/path_to_submodule
but go ahead and backup your whole parent repo directory first.
If you only had one submodule just delete .gitmodules
add a comment |
If you already deleted the submodule directory, like I did, follow the rest of jbmilgrom's instructions. The key is rm -rf .git/modules/path_to_submodule
but go ahead and backup your whole parent repo directory first.
If you only had one submodule just delete .gitmodules
add a comment |
If you already deleted the submodule directory, like I did, follow the rest of jbmilgrom's instructions. The key is rm -rf .git/modules/path_to_submodule
but go ahead and backup your whole parent repo directory first.
If you only had one submodule just delete .gitmodules
If you already deleted the submodule directory, like I did, follow the rest of jbmilgrom's instructions. The key is rm -rf .git/modules/path_to_submodule
but go ahead and backup your whole parent repo directory first.
If you only had one submodule just delete .gitmodules
answered Feb 7 '17 at 21:11
Dmitri R117Dmitri R117
893912
893912
add a comment |
add a comment |
These two commands works for me.
rm path/to/submodule -rf
rm .git/modules/path/to/module -rf
This. It seems there are two ways for submodules to be created. In one of them, the subfolder will only have a single .git file that simply points to a directory in the superproject, starting with.git/modules/
. In there is a folder that stores the repository for the submodule. Deleting that repository fixed the issue for me, while the accepted answer didn't.
– William Randokun
2 days ago
add a comment |
These two commands works for me.
rm path/to/submodule -rf
rm .git/modules/path/to/module -rf
This. It seems there are two ways for submodules to be created. In one of them, the subfolder will only have a single .git file that simply points to a directory in the superproject, starting with.git/modules/
. In there is a folder that stores the repository for the submodule. Deleting that repository fixed the issue for me, while the accepted answer didn't.
– William Randokun
2 days ago
add a comment |
These two commands works for me.
rm path/to/submodule -rf
rm .git/modules/path/to/module -rf
These two commands works for me.
rm path/to/submodule -rf
rm .git/modules/path/to/module -rf
answered Jan 28 at 3:05
W.PerrinW.Perrin
481510
481510
This. It seems there are two ways for submodules to be created. In one of them, the subfolder will only have a single .git file that simply points to a directory in the superproject, starting with.git/modules/
. In there is a folder that stores the repository for the submodule. Deleting that repository fixed the issue for me, while the accepted answer didn't.
– William Randokun
2 days ago
add a comment |
This. It seems there are two ways for submodules to be created. In one of them, the subfolder will only have a single .git file that simply points to a directory in the superproject, starting with.git/modules/
. In there is a folder that stores the repository for the submodule. Deleting that repository fixed the issue for me, while the accepted answer didn't.
– William Randokun
2 days ago
This. It seems there are two ways for submodules to be created. In one of them, the subfolder will only have a single .git file that simply points to a directory in the superproject, starting with
.git/modules/
. In there is a folder that stores the repository for the submodule. Deleting that repository fixed the issue for me, while the accepted answer didn't.– William Randokun
2 days ago
This. It seems there are two ways for submodules to be created. In one of them, the subfolder will only have a single .git file that simply points to a directory in the superproject, starting with
.git/modules/
. In there is a folder that stores the repository for the submodule. Deleting that repository fixed the issue for me, while the accepted answer didn't.– William Randokun
2 days ago
add a comment |
I tried these answers and they didn't work for me. The only thing that worked for me was deleting my parent repo and pulling it down again. Hope this helps somebody
add a comment |
I tried these answers and they didn't work for me. The only thing that worked for me was deleting my parent repo and pulling it down again. Hope this helps somebody
add a comment |
I tried these answers and they didn't work for me. The only thing that worked for me was deleting my parent repo and pulling it down again. Hope this helps somebody
I tried these answers and they didn't work for me. The only thing that worked for me was deleting my parent repo and pulling it down again. Hope this helps somebody
answered Nov 19 '18 at 23:30
Gerard SimpsonGerard Simpson
9041329
9041329
add a comment |
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.
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%2f20929336%2fgit-submodule-add-a-git-directory-is-found-locally-issue%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
A small correction: it's 'repository', not 'depository'. Not really an answer, but if the projects are independent of each other it would be better for each project to have its own repo instead of submodules.
– jcm
Jan 5 '14 at 2:40
Thank you, I corrected. I know but I would like to gather all my work in the same repo but as separate projects. It is a choice to keep my whole work updated when I go from home to my school and vice versa (and to learn how to use these tools, I'm curious ;) )
– vmonteco
Jan 5 '14 at 2:49
Well, curiosity is always a good reason! :) That is strange. Are you sure you haven't added the submodule before?
– jcm
Jan 5 '14 at 2:54
Not in Travail/, and I have no problème to clone fdf.git in ~/ . In Travail/ I find no traces of fdf. just libft :/
– vmonteco
Jan 5 '14 at 3:11
4
Oh wait, I looked in
/Travail/.git/modules/projets/
and I found afdf
directory. This seems to not be in the working tree but in older commits. Could it generate the issue?– vmonteco
Jan 5 '14 at 3:15