Skip to contentSkip to conversation

git add on existing sub-repository

DISCUSSION Stefan Näwe 1 participant 1 message Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

I found a weirdness with git add and submodules.
I did:
- create 2 repos: subtest, mod1
- cloned mod1 into subtest
- in 'subtest': git add mod1

'mod1' gets added as a submodule, but no '.gitmodules' files is written.

Bug ? Feature ?

Thanks for any reply.

Stefan

P.S. Here's a 'script' log of what
I did (git-make-initial simply creates a new repo with a single commit):

~/tmp$ git version
git version 1.6.3.3

~/tmp$ cat ~/bin/git-make-initial
#!/bin/sh
me=$(basename $0)
if [ ! -z "$1" ]; then

	dir=$1
	test -d $dir || mkdir $dir
else
	dir=.

fi
test -d $dir/.git && (echo "$me: '.git' exists; Not creating initial commit" ; exit -1)
test -d $dir/.git || (cd $dir ; git init ; test -f .gitignore || cp .git/info/exclude .gitignore ; git add . ; git ci -s -m"Initial commit created by $me")

~/tmp$ git-make-initial subtest
Initialized empty Git repository in /home/naewe/tmp/subtest/.git/ [master (root-commit) 8ab9920] Initial commit created by git-make-initial

 1 files changed, 6 insertions(+), 0 deletions(-)
 create mode 100644 .gitignore

~/tmp$ git-make-initial mod1
Initialized empty Git repository in /home/naewe/tmp/mod1/.git/ [master (root-commit) 3671274] Initial commit created by git-make-initial

 1 files changed, 6 insertions(+), 0 deletions(-)
 create mode 100644 .gitignore

~/tmp$ ls -la subtest mod1
mod1:
insgesamt 11
drwxr-xr-x 3 naewe naewe 104 2009-07-15 15:38 . drwx------ 13 naewe naewe 6992 2009-07-15 15:38 ..

drwxr-xr-x  8 naewe naewe  328 2009-07-15 15:38 .git
-rw-r--r--  1 naewe naewe  240 2009-07-15 15:38 .gitignore

subtest:
insgesamt 11
drwxr-xr-x 3 naewe naewe 104 2009-07-15 15:38 . drwx------ 13 naewe naewe 6992 2009-07-15 15:38 ..

drwxr-xr-x  8 naewe naewe  328 2009-07-15 15:38 .git
-rw-r--r--  1 naewe naewe  240 2009-07-15 15:38 .gitignore

~/tmp$ cd subtest
~/tmp/subtest$ git clone ~/tmp/mod1
Initialized empty Git repository in /home/naewe/tmp/subtest/mod1/.git/ ~/tmp/subtest$ git add mod1
~/tmp/subtest$ git status
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# new file: mod1
#
# Modified submodules:
#
# * mod1 0000000...3671274 (1):
# > Initial commit created by git-make-initial
#
~/tmp/subtest$ ls -a
. .. .git .gitignore mod1
~/tmp/subtest$