git 您可以在单个 repo 中为每个目录添加额外的 .gitignore 吗?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9730486/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 13:13:26  来源:igfitidea点击:

Can you have additional .gitignore per directory within a single repo?

gitversion-controlrepositorygitignore

提问by B Seven

Can you create a .gitignore file in a directory that only applies to files (and directories) within that directory?

您能否在仅适用于该目录中的文件(和目录)的目录中创建 .gitignore 文件?

回答by Mike Morearty

Yes, you can. Try it, it works fine. Put a .gitignorein the root of your repo, and put another .gitignorewith additional things to ignore in a subdirectory.

是的你可以。试试吧,它工作正常。将 a.gitignore放在您的 repo 的根目录中,并.gitignore在子目录中放置另一个要忽略的其他内容。

回答by Tats_innit

回答by learnvst

You can just specify files to ignore in a format such as

您可以仅指定要忽略的文件,例如

Xyz/*.abc

in the .gitignore in the root directory, potentially removing the need for separate ignore files.

在根目录的 .gitignore 中,可能不需要单独的忽略文件。