.gitignore 只包含几个文件
##去除哪些路径
/*
## 保留哪些文件
!my.cnf //
学习其他的
*
!/**/
##去除哪些路径
/dirignore1/
/dirignore2/
##只包含哪些结尾的文件
!*.c
!*.h
!*.cpp
!*.sh
!*.xml
!*.py
!*.md
!*.jar
!.scala
!.java
1 * 代表忽略全部
2 /** 代表文件夹下的全部内容 ( A trailing "/" matches everything inside. For example, "abc/" matches all files inside directory "abc")
为什么要写这句,因为不可能包含一个文件,如果他的文件夹都被忽略了 It is not possible to re-include a file if a parent directory of that file is excluded. (*)
3 包含每个文件后,/dirignore1/, 在去除不需要的文件夹。(可以注意到.gitignore是按照顺序读入规则的,顺序重要)
4 ! 在每行前加感叹号,表示需要包括后面的匹配文件或文件夹
5 /, 连续两个* 表示包含文件夹下的所有内容 (A trailing "/" matches everything inside. For example, "abc/**" matches all files inside directory "abc")
6 (只有在没有 “/” 符号的前提下 , 才会作wildcard匹配, 所以模版中不能加"/"这种路径操作) If the pattern does not contain a slash /, Git treats it as a shell glob pattern and checks for a match against the pathname relative to the location of the .gitignore file
7, 让Git不再管理当前目录下的某些文件。 ! 取反,
*.h 所有以.h结尾的忽略
!a.h 排除a.h,a.h不被忽略
files/*.py[c | a | d] files目录下的,.pya,pyb,pyc结尾的忽略
可以从这里下载对应语言的常用.ginigonre文件:https://github.com/github/gitignore
原文链接:https://blog.csdn.net/u011467621/article/details/79108980
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· Docker 太简单,K8s 太复杂?w7panel 让容器管理更轻松!
2020-12-14 pip升级最新版本