您当前的位置:首页 > 计算机 > 软件应用 > 开发工具(IDE)

玩转一下 git 之 .gitignore 文件

时间:12-14来源:作者:点击数:

gitignore 官方说明(link:https://git-scm.com/docs/gitignore),以下内存摘自 22 Feb 2017 | Using .gitignore the Right Way(link:https://labs.consol.de/development/git/2017/02/22/gitignore.html)

最常用:

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 文件等
方便获取更多学习、工作、生活信息请关注本站微信公众号城东书院 微信服务号城东书院 微信订阅号
推荐内容
相关内容
栏目更新
栏目热门
本栏推荐