当前位置: 首页 > article >正文

git 的 .gitignore 规则文件

# .gitignore 使用注意事项:
# 1. 所有的注释只能是独占单行注释,不能在有效代码后注释!否者不生效!比如错误示范:
#    实例: MDK/ #忽略MDK目录下所有内容 (跟在有效代码后注释,非法!!!)
# 2. 注意务必使用 UTF-8 编码格式去编辑 .gitignore 文件。# .gitignore 使用小提示:
# 1. 提前准备好 .gitignore 文件,再 git init 创建仓,.gitignore规则直接生效;
# 2. 删除MDK下已跟踪的信息:git rm --cached MDK/ -r
# 3. 根据文件夹的排他性,比如.o文件,可以比较检测前后变化,定位变动的.o文件;# 忽略所有.o文件
*.o# 忽略MDK目录下所有内容
MDK/

语法规则

Pattern Syntax

Here are some common patterns and how they match:

PatternExplanation/MatchesExamples
Blank lines are ignored
text commentLines starting with # are ignored
nameAll name files, name folders, and files and folders in any name folder/name.log
/name/file.txt
/lib/name.log
name/Ending with / specifies the pattern is for a folder. Matches all files and folders in any name folder/name/file.txt
/name/log/name.log

no match:
/name.log
name.fileAll files with the name.file/name.file
/lib/name.file
/name.fileStarting with / specifies the pattern matches only files in the root folder/name.file

no match:
/lib/name.file
lib/name.filePatterns specifiing files in specific folders are always realative to root (even if you do not start with / )/lib/name.file

no match:
name.file
/test/lib/name.file
**/lib/name.fileStarting with ** before / specifies that it matches any folder in the repository. Not just on root./lib/name.file
/test/lib/name.file
**/nameAll name folders, and files and folders in any name folder/name/log.file
/lib/name/log.file
/name/lib/log.file
/lib/**/nameAll name folders, and files and folders in any name folder within the lib folder./lib/name/log.file
/lib/test/name/log.file
/lib/test/ver1/name/log.file

no match:
/name/log.file
*.fileAll files withe .file extention/name.file
/lib/name.file
*name/All folders ending with name/lastname/log.file
/firstname/log.file
name?.file? matches a single non-specific character/names.file
/name1.file

no match:
/names1.file
name[a-z].file[range] matches a single character in the specified range (in this case a character in the range of a-z, and also be numberic.)/names.file
/nameb.file

no match:
/name1.file
name[abc].file[set] matches a single character in the specified set of characters (in this case either a, b, or c)/namea.file
/nameb.file

no match:
/names.file
name[!abc].file[!set] matches a single character, except the ones spesified in the set of characters (in this case a, b, or c)/names.file
/namex.file

no match:
/namesb.file
*.fileAll files withe .file extention/name.file
/lib/name.file
name/
!name/secret.log
! specifies a negation or exception. Matches all files and folders in any name folder, except name/secret.log/name/file.txt
/name/log/name.log

no match:
/name/secret.log
*.file
!name.file
! specifies a negation or exception. All files withe .file extention, except name.file/log.file
/lastname.file

no match:
/name.file
*.file
!name/*.file
junk.*
Adding new patterns after a negation will re-ignore a previous negated file
All files withe .file extention, except the ones in name folder. Unless the file name is junk
/log.file
/name/log.file

no match:
/name/junk.file
http://www.lryc.cn/news/2383582.html

相关文章:

  • 【通用智能体】Serper API 详解:搜索引擎数据获取的核心工具
  • asp.net web form nlog的安装
  • 【图像生成大模型】CogVideoX-5b:开启文本到视频生成的新纪元
  • 剧本杀小程序:指尖上的沉浸式推理宇宙
  • 2024正式版企业级在线客服系统源码+语音定位+快捷回复+图片视频传输+安装教程
  • 深入解析 Oracle session_cached_cursors 参数及性能对比实验
  • 【RabbitMQ】整合 SpringBoot,实现工作队列、发布/订阅、路由和通配符模式
  • k8s面试题-ingress
  • Node.js Express 项目现代化打包部署全指南
  • 分布式电源的配电网无功优化
  • 【WebRTC】源码更改麦克风权限
  • upload-labs通关笔记-第15关 文件上传之getimagesize绕过(图片马)
  • idea无法识别Maven项目
  • 前端三剑客之HTML
  • linux中cpu内存浮动占用,C++文件占用cpu内存、定时任务不运行报错(root) PAM ERROR (Permission denied)
  • RabbitMQ的核心原理及应用
  • 实时监控服务器CPU、内存和磁盘使用率
  • linux国产机安装GCC
  • python训练营打卡第30天
  • 时间序列预测实战:用 LSTM 预测股票价格
  • STM32 | FreeRTOS 消息队列
  • 便捷的Office批量转PDF工具
  • pom.xml中的runtime
  • SpringMVC 通过ajax 实现文件的上传
  • opcUA 编译和建模入门教程(zhanzhi学习笔记)
  • 【关联git本地仓库,上传项目到github】
  • 初步认识HarmonyOS NEXT端云一体化开发
  • WebRTC技术EasyRTC音视频实时通话驱动智能摄像头迈向多场景应用
  • 分布式ID生成器:原理、对比与WorkerID实战
  • java 代码查重(三)常见的距离算法和相似度(相关系数)计算方法