问题描述
出于各种原因,我在项目根目录的 .gitignore
中输入:
For various reasons, I have the entry in my .gitignore
in the root of a project:
*.c
如我所愿,这会忽略所有C文件从被包括在内。但是,我真的只希望只在根目录中忽略C文件,而不是所有的子目录:
As I desire, this ignores all C files from being included. However, I really only want the C files to only be ignored in the root directory, and not all the sub-directories:
foo.c
bar.c
folder/baz.c
以上方案,我只想要忽略foo.c和bar.c。我不希望这个gitignore规则递归地工作。我如何做到这一点?
In the above scheme, I only want foo.c and bar.c ignored. I do not want this gitignore rule to work recursively. How do I do this?
我知道可以用!*。c
来否定规则, ,但我宁愿不要为每个子目录都这样做。 (这是我现在正在做的)。
I'm aware of being able to negate the rule with !*.c
, but I'd rather not do that for every subdirectory. (This is what I am currently doing).
推荐答案
您想这样做:
/*.c
从手册页找一些引用,并发现这个确切的例子在那里!哎呀!
I was looking for a bit from the manpage to quote, and found that this exact example's in there! Oops!
这篇关于限制.gitignore的深度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!