git config 配置修改

Git 配置文件

  Git 自帶一個 git config 的工具來幫助設置控制 Git 外觀和行爲的配置變量。 這些變量存儲在三個不同的位置:

  • /etc/gitconfig 文件: 包含系統上每一個用戶及他們倉庫的通用配置。 如果使用帶有 --system 選項的 git config 時,它會從此文件讀寫配置變量。
  • ~/.gitconfig~/.config/git/config 文件:只針對當前用戶。 可以傳遞 --global 選項讓 Git 讀寫此文件。
  • 當前使用倉庫的 Git 目錄中的 config 文件(就是 .git/config):針對該倉庫。

  每一個級別覆蓋上一級別的配置,所以 .git/config 的配置變量會覆蓋 /etc/gitconfig 中的配置變量。


用戶信息

  當安裝完 Git 應該做的第一件事就是設置你的用戶名稱與郵件地址。 這樣做很重要,因爲每一個 Git 的提交都會使用這些信息,並且它會寫入到你的每一次提交中,不可更改:

配置用戶名
$ git config --global user.name "loushengyue"
查看已配置的用戶名
$ git config --global user.name
loushengyue
配置郵箱
$ git config --global user.email [email protected]
查看已配置的郵箱
$ git config --global user.email
[email protected]

如何查看".gitconfig"文件

  在"Git Bash"命令行工具中輸入“cd && ls -a”便可以看到如下信息:

$ cd && ls -a
 ./
 ../
 .android/
 .bash_history
 .config/
 .eclipse/
 .gem/
 .gitbook/
 .gitconfig
  ……

  再通過“view .gitconfig”命令打開.gitconfig文件,即可查看該配置文件內容:

[user]
		name = loushengyue
		email = [email protected]
[filter "lfs"]
		smudge = git-lfs smudge -- %f
		process = git-lfs filter-process
		required = true
		clean = git-lfs clean -- %f

檢查配置信息

  通過“git config --list”命令也可以查看git的配置信息,例如:

$ git config --list
core.symlinks=false
core.autocrlf=true
core.fscache=true
color.diff=auto
color.status=auto
color.branch=auto
color.interactive=true
help.format=html
rebase.autosquash=true
http.sslcainfo=C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt
http.sslbackend=openssl
diff.astextplain.textconv=astextplain
filter.lfs.clean=git-lfs clean -- %f
filter.lfs.smudge=git-lfs smudge -- %f
filter.lfs.required=true
filter.lfs.process=git-lfs filter-process
credential.helper=manager
user.name=loushengyue
user.email=[email protected]
……


歡迎點贊,謝謝關注:)

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章