Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
由于各种原因,我在.gitignore项目的根目录中有以下条目:
.gitignore
*.c
如我所愿,这会忽略所有 C 文件。但是,我真的只希望只在根目录中忽略 C 文件,而不是所有子目录:
foo.c bar.c folder/baz.c
在上面的方案中,我只希望 foo.c 和 bar.c 被忽略。我不希望这个 gitignore 规则递归地工作。我该怎么做呢?
我知道可以用 来否定规则!*.c,但我不想对每个子目录都这样做。(这是我目前正在做的)。
!*.c
你想这样做:
/*.c
我正在从手册页中寻找一些引用,发现这个确切的例子就在那里!哎呀!
前导斜杠匹配路径名的开头。例如,"/*.c"匹配"cat-file.c"但不匹配"mozilla-sha1/sha1.c"。
"/*.c"
"cat-file.c"
"mozilla-sha1/sha1.c"