本文要點:
1. 版本管理的好處
2. Git 的優(yōu)點
3. 配置 Git
3.1. 配置開發(fā)者的信息
3.2. 配置級別
1. 版本管理的好處
- 方便合作
- 記錄版本
- 記錄歷史版本
- 額外元信息
- 備份
2. Git 的優(yōu)點
- 直接記錄快照,而非差異比較
- 大部分操作在本地
- 對數(shù)據(jù)做校驗
- 一般數(shù)據(jù)都只能添加,很少有不可逆操作
3. 配置Git
3.1. 配置開發(fā)者的信息
git config [--global|--local] <config-name> <config-value> # 設(shè)置配置值
git config [--global|--local] <config-name> # 輸出配置值
實例:
git config --global user.name "DongshuangZhao"
git config --global user.email imtoby@126.com
git config --global core.editor vim
為什么一定設(shè)置 user.name
和 user.email
呢?因為它們是修改的一部分;如若不設(shè)置的話,可能提交到版本管理中的電子郵箱是我們的私人郵箱。
3.2. 配置級別
配置級別 | 配置位置 | 命令行 |
---|---|---|
系統(tǒng)級別 | /etc/gitconfig |
--system |
用戶級別 | ~/.gitconfig |
--global |
項目級別 | <path/to/project/>.git/config |
--loccal |
使用 git config --list
可以列出所有配置:
$ git config --list
diff.astextplain.textconv=astextplain
filter.lfs.clean=git-lfs clean -- %f
filter.lfs.smudge=git-lfs smudge -- %f
filter.lfs.process=git-lfs filter-process
filter.lfs.required=true
http.sslbackend=openssl
http.sslcainfo=C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt
core.autocrlf=true
...# 以下略