I have a major problem with git pull when dealing with submodules. I thought I started understanding their principle but apparently not...
I created a simple git repo Super
and created a submodule module
in it. My first issue is when make a commit in module
(I add a text file) and push the code, I can see that on github that the text file does not go into the submodule module
but in fact goes into the superproject Super
(the submodule does not even show in github). So when I do a git pull in Super
I end up with the text file in the local copy of my repo that I already pushed in my submodule... I am not sure what I am doing wrong. here is the code basically:
cd module (a text file "Test" was added to be commited)
~/Super/module [master]: git add -A
~/Super/module [master]: git commit -m 'comment'
~/Super/module [master]: git push
cd Super
~/Super [master] : git pull
and now the text file "Test" shows up in my Super next to the submodule "module".
So this is already problematic but I can live with that. I now go into my Super
and delete this text file and add the changes made to the submodule module
in order to repoint the latest submodule commit.
(after deleting the text file )
~/Super [master] : git add -A
~/Super [master] : git commit -m 'comment 2'
~/Super [master] : git submodule update
~/Super [master] : git pull
~/Super [master] : git push
I now go in my submodule and do a git pull
~/Super/module [master]: git pull
and this create a copy of everything that is in the super and put it in the submodule module
. So if I do a ls
in module
I find a nested submodule module
, which is a big problem.
~/Super/module/module [master]:
So I basically have 2 problems :
When I push my submodule a copy goes to the superproject
when pulling in my submodule after updating my superproject, it creates a nested submodule.
Can anybody out there tell me what I am doing wrong? I am very sorry if this might seem obvious to you guys, but I have been stuck on this problem for while and it is very frustrating.
I have added the .gitmodules files and .git/config from the Super:
.gitmodules:
[submodule "module"]
path = module
url = git@github.com:titocazou/Super.git
.git/config:
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
url = git@github.com:titocazou/Super.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
[submodule "module"]
url = git@github.com:titocazou/Super.git