接上一篇,git config命令使用第一篇——介紹,基本操作,增刪改查:http://blog.csdn.net/hutaoer06051/article/details/8275069
1. 刪除一個section
命令參數 --remove-section
格式:git config [--local|--global|--system] --remove-section section
使用這個命令,不僅可以刪除一個沒有內容的section,而且即使該section下面有內容,也會一起刪除掉
比如我們來刪除這樣一個配置:
直接使用命令: git config --local --remove-section dog,這樣可以把dog下面的內容全部刪除,而且也能刪除掉section
2.?查看value類型
一共可以查看四種類型:--bool, --int, --bool-or-int, --path
格式:git config [--local|--global|--system] [--bool|--int|--bool-or-int|--path] section.key
使用示例:git config --local --bool dog.name
如果dog.name不是布爾值,且也不能被轉化為bool值,那么git就會報錯;否則git會顯示true或false?
3. 操作特殊的section
看看這類sectino長什么樣子的
這類section后面還跟了一個字段,例如[remote "origin"]
對這類section應該如何使用git config進行操作呢?很簡單把section后面的字段也作為section的key寫進去,這樣會多一層嵌套,但是忽略了這一層就會報錯了
比如我們要對[remote "master"]下的url做修改,git config --local remote.origin.url ?value,value為修改后的值,這樣就ok啦,而增刪改查都是一樣的
4.?重命名section
參數:--rename-section
格式:git config [--local|--global|--system] --rename-section section1 section2
比如我們把名為dog的section改為dog1, git config --local rename-section dog dog1,這樣就好咯
5.?替換,獲取和刪除多個屬性
參數:--replace-all, --get-all, -unset-all
如果此時,配置中有,dog.a=dddd,同時還有dog.a = aaaa,如下圖
然后,可以對這些進行修改, git config --local --replace-all dog.a 333
這時候dog.a值均被替換,且只保留最后一個,這個是需要注意的
獲取配置中所有dog.a的value值
刪除配置中所有dog.a的value值
6. 運用正則初步
參數: --replace-all, --get-regexp
正則很強大,同樣的,在git中也很強大,git中并沒有專門的獲取某個section下面所有key值value的方法,但是試用--get-regexp這個參數就可以實現
例如我們來獲取配置中的core下面的所有key值的value
使用命令:get config --local --get-regexp core 即可
--replace-all中也可以使用正則的
下一篇,我會給大家介紹一下常用的git配置,敬請期待
?