parent
f9461ac0c3
commit
d9ed56a390
48
docs/git.md
48
docs/git.md
@ -341,19 +341,43 @@ $ git log --stat -M
|
||||
|
||||
### 忽略文件
|
||||
|
||||
```gitignore showLineNumbers
|
||||
/logs/*
|
||||
# “!” 意思是不要忽视
|
||||
!logs/.gitkeep
|
||||
# 忽略 Mac 系统文件
|
||||
.DS_store
|
||||
# 忽略 node_modules 文件夹
|
||||
node_modules
|
||||
# 忽略 SASS 配置文件
|
||||
.sass-cache
|
||||
```
|
||||
`.gitignore` 文件指定了 Git 应该忽略的 **未跟踪的** 文件。
|
||||
|
||||
`.gitignore` 文件指定了 Git 应该忽略的未跟踪的文件
|
||||
- 当面 `.gitignore` 文件定义规则的优先级高于上级路径 `.gitignore` 定义规则的优先级;后定义的规则优先级高于前面定义规则的优先级。
|
||||
- 空行不匹配任何文件,可用于增加文件可读性。
|
||||
- 以`#`开头的行为全行注释,不支持行尾类注释。如果希望匹配以`#`开头的文件或文件夹,可前缀`\`进行转义。
|
||||
- 行尾空格默认被忽略,除非前缀`\`进行转义。行首空格会被正常处理,不会被忽略。
|
||||
- 行首`!`表示否定模式。如果匹配的文件被其他低优先级规则忽略,则会被重新跟踪。如果希望匹配以`!`开头的文件或文件夹,可前缀`\`进行转义。
|
||||
- 统一用`/`表示路径分隔符,不区分操作系统。
|
||||
- 如果规则包含路径分隔符`/`,则仅在指定的文件夹这一层级进行文件搜索匹配,不会递归搜索子目录;如果规则不含路径分隔符,则会在当前文件夹内进行递归搜索匹配。
|
||||
- 如果规则以路径分隔符`/`结尾,则仅会匹配文件夹;否则会匹配文件和文件夹。
|
||||
- 通配符不能匹配`/`。`*`匹配任意个数字符,`?`匹配任意一个字符,更多细节参见[glob(7)](https://man7.org/linux/man-pages/man7/glob.7.html)。
|
||||
- 双星`**`匹配任意路径。以`**`开头表示在全部文件夹下去匹配,以`/**`结尾表示匹配指定文件夹下的全部内容,中间`**`匹配任意深度路径。
|
||||
|
||||
```gitignore showLineNumbers
|
||||
# 忽略当前目录logs文件夹下的全部内容
|
||||
/logs/
|
||||
/logs/*
|
||||
/logs/**
|
||||
# 上述几条规则等效
|
||||
|
||||
# 忽略 Mac 系统文件,包括任意子路径下的同名文件(夹)
|
||||
.DS_store
|
||||
|
||||
# 忽略 node_modules 文件夹,包括任意子路径下的同名文件夹
|
||||
node_modules/
|
||||
|
||||
# 忽略任意子路径下build、target文件夹,但不忽略src/main、src/test下的build、target文件夹
|
||||
build/
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
target/
|
||||
!**/src/main/**/target/
|
||||
!**/src/test/**/target/
|
||||
|
||||
# 使用 ! 重新包含指定文件(夹)
|
||||
!logs/.gitkeep
|
||||
```
|
||||
|
||||
### git 配置 ssh 代理
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user