我如何忽略我的git仓库根目录下的一个目录,但将它进一步包含在树中? [英] How do I ignore a directory in the root of my git repository, but include it further down in the tree?
问题描述
我需要使用 .gitignore
来排除我的存储库根目录。但是,其他具有相同名称的目录在目录树中存在更深,我需要包含这些目录。看起来,当我将目录名称放入 .gitignore
时,它会捕获所有这些目录,而不仅仅是我需要忽略的目录。我知道 .gitignore
实际上不是文件列表,而是模式。那么如何构造一个模式来忽略我的根目录中的文件,而不是进一步下载同名文件? 解决方案
p>使用领导/
/file.x
这只会匹配一个顶级文件,而不是一个较低的文件,在want / file.x中说。
I need to use .gitignore
to exclude a directory in the root of my repository. However, other directories with the same name exist deeper in the directory tree, and I need those to be included. It seems that when I put the name of the directory into .gitignore
, it catches all of these directories, not just the one I need to ignore. I understand that .gitignore
is actually not a list of files, but patterns. So how can I construct a pattern to ignore just a file in my root directory, but not files with the same name further down?
Use a leading /
/file.x
That will only match a top level file.x but not one lower down, in "want/file.x", say.
这篇关于我如何忽略我的git仓库根目录下的一个目录,但将它进一步包含在树中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!