I'm trying to learn about submodules, and I am currently having just this problem.
What I don't understand is the following: isn't a submodule supposed to have a .git file? (but maybe not a folder (i.e. directory)
In the example below, the .git file in the submodule directory has a relative path back to the .git/modules directory in the parent directory (what the example calls the superproject.
In the example worked out in Version Control with Git (3rd edition, pp 355-356) the author does the following
% mkdir superproject
% cd superproject
% git init -b main
% echo "superproject" > sp-readme.md
% git add .
% git commit -m "add sp-readme.md"
and then, adds the submodule
% git submodule add git@github.com:ppremk/example-submodule-updated.git
Cloning into '<...>/superproject3/example-submodule-updated'...
remote: Enumerating objects: 6, done.
remote: Counting objects: 100% (6/6), done.
remote: Compressing objects: 100% (5/5), done.
Receiving objects: 100% (6/6), done.
remote: Total 6 (delta 0), reused 6 (delta 0), pack-reused 0
% git commit -m "added submodule"
[main 6683546] added submodule
2 files changed, 4 insertions(+)
create mode 100644 .gitmodules
create mode 160000 example-submodule-updated
% git status
On branch main
nothing to commit, working tree clean
% ll example-submodule-updated
total 24
drwxr-xr-x@ 5 whdaffer 703763885 160 Jan 31 18:14 ./
drwxr-xr-x@ 6 whdaffer 703763885 192 Jan 31 18:14 ../
-rw-r--r--@ 1 whdaffer 703763885 50 Jan 31 18:14 .git
-rw-r--r--@ 1 whdaffer 703763885 62 Jan 31 18:14 README.md
-rw-r--r--@ 1 whdaffer 703763885 59 Jan 31 18:14 new-file.md
% file example-submodule-updated/.git
example-submodule-updated/.git: ASCII text
% cat example-submodule-updated/.git
gitdir: ../.git/modules/example-submodule-updated
Looking at the directory that the submodule .git file mentions, it looks like a normal .git directory for a stand-alone repo.
% cd example-submodule-updated
% ll ../.git/modules/example-submodule-updated
total 40
drwxr-xr-x@ 12 whdaffer 703763885 384 Jan 31 18:15 ./
drwxr-xr-x@ 3 whdaffer 703763885 96 Jan 31 18:14 ../
-rw-r--r--@ 1 whdaffer 703763885 21 Jan 31 18:14 HEAD
-rw-r--r--@ 1 whdaffer 703763885 364 Jan 31 18:14 config
-rw-r--r--@ 1 whdaffer 703763885 73 Jan 31 18:14 description
drwxr-xr-x@ 15 whdaffer 703763885 480 Jan 31 18:14 hooks/
-rw-r--r--@ 1 whdaffer 703763885 217 Jan 31 18:15 index
drwxr-xr-x@ 3 whdaffer 703763885 96 Jan 31 18:14 info/
drwxr-xr-x@ 4 whdaffer 703763885 128 Jan 31 18:14 logs/
drwxr-xr-x@ 4 whdaffer 703763885 128 Jan 31 18:14 objects/
-rw-r--r--@ 1 whdaffer 703763885 112 Jan 31 18:14 packed-refs
drwxr-xr-x@ 5 whdaffer 703763885 160 Jan 31 18:14 refs/
So, my question to those who suggest removing the .git file in the submodule directory: doesn't that destroy the characteristic of the subdirectory as a submodule and just turn it into a regular subdirectory of the parent? Meaning that it no longer tracks the changes that the submodule comes from.
Keep in mind, I'm just learning this part of git, and having problems to boot, so I could be asking a stupid question.
If so, please advise.