What happens if I'm creating the initial commit from my working (parent) directory, but there are subdirs with independently checked-out git repos?
I simply did git add .
but that brought me to a strange situation when the subdirs with nested Git repos are not registered as submodules of the parent repo.
So: how to proceed after an initial "git add ." in a parent working dir where there have been subdirs with independetly checked-out nested git repos (in order to get correct submodules)?
An example:
[imz@z super-existing-sub]$ ls
c sub
[imz@z super-existing-sub]$ ls -a sub/
. .. a .git
[imz@z super-existing-sub]$
So, there is already a pre-existing super-existing-sub/sub
git repo inside super-existing-sub
.
After I run in super-existing-sub
:
$ git init
$ git add .
what can be done to correctly register the pre-existing Git repo as a submodule?
Now, Git somehow has tracked it:
$ git status
On branch master
Initial commit
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: c
new file: sub
$
but git submodule
has some problems:
$ git submodule status
No submodule mapping found in .gitmodules for path 'sub'
$
How to convert it to a correct submodule?
I tried to proceed the way that was suggested in the answer (composed by Victor and me), namely git submodule add URL subdir
, but that breaks unfortunately:
$ git submodule status
No submodule mapping found in .gitmodules for path 'wp-content/themes/liquorice'
$ git submodule add git@github.com:/nudgeme/Liquorice.git ./wp-content/themes/liquorice
'wp-content/themes/liquorice' already exists in the index
/sshx:kosmoplus:/home/kosmoplus/kosmoplus.ru.old $ git submodule status
No submodule mapping found in .gitmodules for path 'wp-content/themes/liquorice'
$