Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

We've been looking into git submodules and we are wondering what advantage (if any) is there in having a repository using submodules verses having a repository within another repository with a .gitignore file.

Example without submodules:

mkdir a
cd a
git init
touch test1.txt
echo "b" > .gitignore
git add .
git commit -m "Adding test1.txt and gitignore"

mkdir b
cd b
git init
touch test2.txt
git add .
git commit -m "Adding test2.txt"

git log
cd ..
git log
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
786 views
Welcome To Ask or Share your Answers For Others

1 Answer

The git parent (of the submodules) will keep track of the branches and tag IDs of the submodules when you commit. That will ensure that when you check out the parent (at a known version) then the submodules will also contain their right tags.

If, as above, it just happens to be an ignored subdirectory, then basically these are two independent git repos, as if they'd not been part of a file system hierarchy.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...