是否可以将带有 .git 文件夹的子文件夹添加到存储库,而 Git 不将其视为子模块?我尝试了不同的方法来忽略该 .git 文件夹,但到目前为止没有任何效果。
我在/.gitignore 中尝试过:
/vendor/**/.git/
..并在/vendor/.gitignore 中:
.git/
我想忽略的 .git 文件夹在/vendor/foo/bar/中。
最佳答案
您可以通过先直接添加一些(任何)内部内容来做到这一点。 Git 在搜索新遇到的目录时通过遇到 .git
条目来检测子模块,但如果您给它一个实际路径以在该目录中查找,它不会搜索。
所以
git add path/to/some/submodule/file # bypass initial search that detects .git
git add path/to/some/submodule # now git's index has it as ordinary dir
关于git - 忽略子文件夹中的 .git 文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22685170/