git configuration
git的配置文件結構
git的配置文件由section名和變量名組成
[user]
name = abc
emial = example.com
[]里面的user就是section名,section只能由字母,數字,-和.組成,并且不區分大小寫;name和email是變量名,變量名只能是數字,字母和-組成,并且也不區分大小寫。
當我們使用git config user.name "abc"來進行設置時,user.name就是由section名和變量名組合而成,由.分割開來。
?
git配置文件的subsection
1)在git的配置文件中,一個section可以由subsection,定義一個subsection有兩種形式: [section "subsection"]和[section.subsection],區別是前者的subsection名區分大小寫,而后者的subsection名不區分大小寫。除了newline之外,任何字符都可以作為subsection名
?
2)定義了section后可以定義subsection,但是定義subsection時不是必須要定義section
git配置文件的類型
git的配置文件有3類,優先級從小到大依次為:
1) .git/config 這個配置文件定義的變量作用域是整個repository,使用git config --file操作這個文件,這也是git config命令默認操作的配置文件
2) ~/.gitconfig 這個配置文件定義的變量作用域是user,使用git config --global操作這個文件
3)/etc/gitconfig 這個配置文件定義的變量作用域是system,使用git config --system操作這個文件
?
git配置文件變量的定義,刪除,查看
//配置文件變量的定義,注意變量名和值之間沒有等號,而是用空格分隔 git config --global user.name "lucy"//配置文件變量的刪除 git config --global --unset user.name//配置文件變量的查看,這里不是僅列出.git/config下的變量,而是列出全部配置文件下的變量 //不同配置文件中的同名變量都會被列舉出來 git config -l定義別名
git config命令的另一個作用就是定義別名:
?
//注意別名的值用引號包圍,并且別名和值之間沒有等號,而是用空格分隔 git config --global alias.show-graph "log --graph --abbrev-commit --pretty=oneline"?
轉載于:https://www.cnblogs.com/chaoguo1234/p/5323083.html
總結
以上是生活随笔為你收集整理的git configuration的全部內容,希望文章能夠幫你解決所遇到的問題。