限制.gitignore的深度 [英] Limit depth of .gitignore

查看:96
本文介绍了限制.gitignore的深度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

出于各种原因,我在项目根目录的 .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!


前导斜杠匹配路径名的开头。例如,/ *。c匹配cat-file.c但不是mozilla-sha1 / sha1.c

这篇关于限制.gitignore的深度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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