简体   繁体   English

.gitignore取消忽略.cc文件

[英].gitignore un-ignore .cc files

I have a .gitignore file in which I ignore everything, and then un-ignore specific files and directories. 我有一个.gitignore文件,其中我忽略所有内容,然后忽略特定的文件和目录。 However, one part of it doesn't seem to work. 但是,其中的一部分似乎不起作用。

/*

!.gitignore
!Makefile
!include/
!src/
!test/*.cc

**.swp

New *.cc files in the test directory don't appear in git status . test目录中的新*.cc文件不会以git status出现。

The /* rule causes the test directory to be ignored, so git never descends into it at all. /*规则使test目录被忽略,因此git绝对不会降入该目录。 Therefore your !test/*.cc rule has no effect. 因此,您的!test/*.cc规则无效。

You need a sequence of alternating and overlapping rules like this: ignore everything, then un-ignore test , then ignore everything under test , then un-ignore the .cc files within test . 你需要交替的序列和重叠的规则是这样的:不顾一切,然后取消忽略test ,则忽略下的一切test ,然后取消忽略.cc中的文件test

/*
!test
test/*
!test/*.cc

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM