Limit depth of .gitignore

喜欢而已 提交于 2019-12-22 10:50:00

问题


For various reasons, I have the entry in my .gitignore in the root of a project:

 *.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

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?

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).


回答1:


You want to do this:

/*.c

I 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".



来源:https://stackoverflow.com/questions/3551569/limit-depth-of-gitignore

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!