.gitignore文件的对面? [英] opposite of .gitignore file?

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

问题描述


可能存在重复:


Possible Duplicate:
Make .gitignore ignore everything except a few files

是否有可能让git默认忽略所有文件,除非在特殊文件中指定?

Is it possible to let git ignore all files by default, unless specified in a special file?

推荐答案

您可以包含!-lines到白名单文件:a .gitignore:

You can include !-lines to whitelist files: a .gitignore with:

*
!included/

会排除all,但'included /'目录

will exclude all, but the 'included/' directory

请注意,如果您希望文件匹配模式不被忽略,在子目录中,您需要防止包含的目录也被忽略了。这应该不会造成大问题,因为git实际上不会跟踪目录,只有文件(由存储库路径标识)。

Note that if you want files matching a pattern to be un-ignored, in subdirectories, you will need to prevent the containing directories from getting ignored too. This should not pose a large problem, since git doesn't actually track directories, only files (identified by a repository path).

示例:

*
!*/
!SOURCES

将忽略所有内容,除了子目录中的 SOURCES

will ignore everything, except SOURCES in subdirectories.

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

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