忽略子文件夹中的.git文件夹
是否可以将带有.git文件夹的子文件夹添加到仓库中,而Git却不将其视为子模块呢?我尝试了其他方法来忽略该.git文件夹,但到目前为止没有任何效果.
Is it possible to add a sub folder with a .git folder to a repo, without Git treating it like a submodule? I've tried different methods to ignore that .git folder, but nothing this far has worked.
我在/.gitignore中尝试过:
I have tried in /.gitignore:
/vendor/**/.git/
..和/vendor/.gitignore中的
..and in /vendor/.gitignore:
.git/
我要忽略的.git文件夹位于/vendor/foo/bar/中.
The .git folder I want to ignore is in /vendor/foo/bar/.
您可以通过直接直接添加一些(任何)内部内容来做到这一点.Git在搜索新遇到的目录时会遇到 .git
条目来检测子模块,但是如果给它提供在该目录中查找的实际路径,它将不会搜索.
You can do this by directly adding some (any) internal content first. Git detects submodules by encountering the .git
entry when searching a newly-encountered directory, but if you give it an actual path to look for inside that directory it doesn't search.
所以
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