本文中使用到的参数
配置文件内容实例如下:
如上面示例。
在~/.gitconfig及/etc/gitconfig增加分别如下:
2)删除配置选项
3)查看某个选项的值
4)指定配置文件
增加修改
查看
删除
三、常用配置
1)用户邮箱
2)别名
3)开启颜色显示
-e 编辑配置文件
--global 全局配置 ~/.gitconfig
--system 系统配置 /etc/gitconfig
--unset 删除配置项
一、配置文件
$ cd /path/to/workspace/source/
$ git config -e
编辑 /path/to/workspace/source/.git/config
$ git config -e --global
编辑 ~/.gitconfig
$ git config -e --system
编辑 /etc/gitconfig
配置文件内容实例如下:
[core]
repositoryformatversion = 0
filemode = false
logallrefupdates = true
[remote "origin"]
url = "........."(不能外链,故删掉了)
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
[branch "3.2.0.RC2"]
remote = origin
merge = refs/heads/3.2.0.RC2
二、git配置INI文件
git配置文件采用的INI文件格式,git config命令可对INI文件进行操作
1)增加配置项:
$ git config user.name "Silenter Wat"
$ git config user.email "xxxxxx"
.git/config文件中增加结果如下
[user]
name = Silenter Wat
email = xxxxxx
$ git config x.y.z b
结果如下
[x "y"]
z = b
其中选项的名字可以是任意的,不会报错,但是git命令可能不会使用的
如上面示例。
在~/.gitconfig及/etc/gitconfig增加分别如下:
$ git config --global user.name "Silenter Wat"
$ git config --global user.email "xxxxxx"
$ git config --system user.name "Silenter Wat"
$ git config --system user.email "xxxxxx"
2)删除配置选项
$ git config --unset u.t
$ git config --unset --global user.name
$ git config --unset --system user.email
会删除掉u.t配置项
3)查看某个选项的值
$ git config user.name
Silenter Wat
4)指定配置文件
增加修改
$ GIT_CONFIG=test.ini git config a.b.c.d "Hello world"
$ vim test.ini
[a "b.c"]
d = Hello world
查看
$ GIT_CONFIG=test.ini git config a.b.c.d
删除
$ GIT_CONFIG=test.ini git config --unset a.b.c.d
三、常用配置
1)用户邮箱
$ git config --global user.name "Silenter Wat"
$ git config --global user.email "xxxxxx“
2)别名
$ git config --system alias.st status
$ git config --system alias.ci commit
$ git config --system alias.co checkout
$ git config --system alias.br branch
3)开启颜色显示
$ git config --global color.ui true