出于各种原因,我在项目根目录下的.gitignore中输入:
*.c如我所愿,这会忽略所有C文件被包含在内。 但是,我真的只想让C文件只在根目录中被忽略,而不是所有的子目录:
foo.c bar.c folder/baz.c在上面的方案中,我只想要忽略foo.c和bar.c。 我不希望这个gitignore规则递归地工作。 我该怎么做呢?
我知道可以用!*.c来否定规则,但我宁愿不为每个子目录都这样做。 (这是我目前正在做的)。
For various reasons, I have the entry in my .gitignore in the root of a project:
*.cAs 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.cIn 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?
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我正在寻找一些从引用页面引用,并发现这个确切的例子在那里! 哎呀!
前导斜杠匹配路径名的开头。 例如, "/*.c" "mozilla-sha1/sha1.c" . "/*.c"与"cat-file.c" "/*.c"匹配,但不匹配"mozilla-sha1/sha1.c" 。
You want to do this:
/*.cI was looking for a bit from the manpage to quote, and found that this exact example's in there! Oops!
A leading slash matches the beginning of the pathname. For example, "/*.c" matches "cat-file.c" but not "mozilla-sha1/sha1.c".
更多推荐
发布评论