玩转一下 git 之 .gitignore 文件
gitignore 官方说明,以下内存摘自 22 Feb 2017 | Using .gitignore the Right Way
最常用:
entry | Ignores every… |
---|---|
target/ | …folder (due to the trailing /) recursively |
target | …file or folder named target recursively |
/target | …file or folder named target in the top-most directory (due to the leading /) |
/target/ | …folder named target in the top-most directory (leading and trailing /) |
*.class | …every file or folder ending with .class recursively |
高级
entry | Ignores every… |
---|---|
#comment | …nothing, this is a comment (first character is a #) |
#comment | …every file or folder with name #comment (\ for escaping) |
target/logs/ | …every folder named logs which is a subdirectory of a folder named target |
target/*/logs/ | …every folder named logs two levels under a folder named target (* doesn’t include /) |
target/**/logs/ | …every folder named logs somewhere under a folder named target (** includes /) |
*.py[co] | …file or folder ending in .pyc or .pyo. However, it doesn’t match .py! |
!README.md | Doesn’t ignore any README.md file even if it matches an exclude pattern, e.g. *.md. NOTE: This does not work if the file is located within a ignored folder. |
更多
- 每个子目录都可以有 .gitignore 来实现精准控制
- 可以全局设置
git config --global core.excludesfile ~/.gitignore_global
来忽略 MacOS 上的 .DS_Store 或者 Windows 上的 thumbs.db 文件等
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
上一篇: 玩转一下正则表达式
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论