@@ -14,16 +14,14 @@ tags:
1414---
1515
1616
17- > 使用 ` .gitignore ` 文件忽略制定文件
17+ > 使用 ` .gitignore ` 文件忽略指定文件
1818
1919## .gitignore
2020
21- 打开 ** SourceTree ** 仓库设置可以发现 仓库忽略列表选项中默认有个 ` .gitignore ` ,用来忽略你不想 ` Commit ` 的文件 。
21+ 在Git中,很多时候你只想将代码提交到仓库,而不是将当前文件目录下的文件全部提交到Git仓库中,例如在MacOS系统下面的 ` .DS_Store ` 文件,或者是Xocde的操作记录,又或者是pod库的中一大串的源代码。这种情况下使用 ` .gitignore ` 就能够在Git提交时自动忽略掉这些文件 。
2222
23- ![ ] ( https://ww1.sinaimg.cn/large/006tNbRwgy1fd07hwkuy5j30vq080t9x.jpg )
2423
25-
26- ## 忽略文件的格式
24+ ## 忽略的格式
2725
2826- ` # ` :此为注释 – 将被 Git 忽略
2927- ` *.a ` :忽略所有 ` .a ` 结尾的文件
3230- ` build/ ` : 忽略 ` build/ ` 目录下的所有文件
3331- ` doc/*.txt ` : 会忽略 ` doc/notes.txt ` 但不包括 ` doc/server/arch.txt `
3432
35- ## 下载地址
33+ ## 创建方法
34+
35+ #### 从 [ github] ( https://github.com/github/gitignore.git ) 上获取
36+
3637github上整理了一些常用需要的项目中需要忽略的文件配置,根据需要进行获取
3738
3839 https://github.com/github/gitignore.git
@@ -47,20 +48,27 @@ github上整理了一些常用需要的项目中需要忽略的文件配置,
4748
4849其他两个在 ` Xcode.gitignore ` 基础上针对不同的语言进行忽略
4950
51+ 将这些文件重写命名为 ` .gittignore `
5052
53+ $ mv Swift.gitignore .gittignore
5154
52- ## 使用方法
55+ #### 通过 [ gitignore.io ] ( https://www.gitignore.io/ ) 创建(推荐)
5356
54- 1 . 将文件拖入项目根目录
57+ ###### 先自定义终端命令:
5558
56- 
59+ macOS下默认是` \#!/bin/bash ` :
60+
61+ $ echo "function gi() { curl -L -s https://www.gitignore.io/api/\$@ ;}" >> ~/.bash_profile && source ~/.bash_profile
5762
58- 2 . 隐藏文件名
63+ 如果是 ` #!/bin/zsh `
5964
60- $ mv Swift.gitignore .gittignore
61-
62- 3 . 忽略特定的文件/文件夹
65+ $ echo "function gi() { curl -L -s https://www.gitignore.io/api/\$@ ;}" >> ~/.zshrc && source ~/.zshrc
6366
64- 将文件名/文件夹名 添加到 `.gittignore` 文件中即可
67+ ###### 使用
68+
69+ 在当前终端目录下
6570
71+ $ gi swift > .gitignore
72+
6673
74+ 就会针对 Swifit 类型的工程创建 ` .gitignore ` 文件。
0 commit comments