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
Can you have additional .gitignore per directory within a single repo?
提问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 .gitignore
in the root of your repo, and put another .gitignore
with additional things to ignore in a subdirectory.
是的你可以。试试吧,它工作正常。将 a.gitignore
放在您的 repo 的根目录中,并.gitignore
在子目录中放置另一个要忽略的其他内容。
回答by Tats_innit
Similar question was: Are multiple `.gitignore`s frowned on?(Jul 2010)
类似的问题是:多个`.gitignore`s 不赞成吗?(2010 年 7 月)
Or if you can have different version of a .gitignore
file per branch: Using github to host public git repositories whilst ensuring that sensitive data files remain untracked(Feb 2010)
或者,如果.gitignore
每个分支可以有不同版本的文件: 使用 github 托管公共 git 存储库,同时确保敏感数据文件保持未被跟踪(2010 年 2 月)
Further perhaps related: How do I tell git to always select my local version for conflicted merges on a specific file?
回答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 中,可能不需要单独的忽略文件。