忽略子文件夹中的.git文件夹 [英] Ignore .git folder in sub folder

查看:101
本文介绍了忽略子文件夹中的.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

这篇关于忽略子文件夹中的.git文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆