我们一直在研究 git 子模块,我们想知道使用子模块的存储库与在另一个存储库中使用 .gitignore 文件的存储库有什么优势(如果有的话)。
没有子模块的例子:
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
最佳答案
(子模块的)git 父级将在您提交时跟踪子模块的分支和标记 ID。这将确保当您 check out 父模块(已知版本)时,子模块也将包含它们的正确标签。
如果如上所述,它恰好是一个被忽略的子目录,那么基本上这是两个独立的 git 存储库,就好像它们不是文件系统层次结构的一部分一样。
关于git - 使用 git 子模块比在另一个带有 gitignore 的 repo 中有一个 repo 有什么优势?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1462754/