# 暂存
git add .gitignore
# 提交
git commit -m "Added .gitignore"
[master 4c40cbe] Added .gitignore
1 file changed, 2 insertions(+)
create mode 100644 .gitignore
# 查看日志
git hist
* 5dc8b1e 2023-05-05 | Added .gitignore (HEAD -> master) [aku]
* b77158a 2023-05-05 | Moved test.txt to lab [aku]
* 929f644 2023-05-05 | Added 123456 to the test.txt [aku]
* d7f681f 2023-05-05 | Added abc to the test.txt (tag: v1) [aku]
* 01b8702 2023-05-05 | Add first file (tag: v1-beta) [aku]
# 查看 Git 状态
$ git status
On branch master
nothing to commit, working tree clean
# 忽略日志文件
*.log
# 上一个配置忽略所有log文件,但是 main.log除外
!main.log
# 只忽略当前目录下的 Log 文件,其它路径下不管
/Log
# 忽略任何目录下名为 build 的文件夹
build/
# 忽略 doc/notes.txt,但不忽略 doc/server/arch.txt
doc/*.txt
# 忽略 doc/ 目录及其所有子目录下的 .pdf 文件
doc/**/*.pdf