Git配置
Git提供了 git config 工具,专门用来配置/读取工作环境变量。
这些变量存放在以下三个不同的地方:
- Git安装目录/etc/gitconfig文件:系统中对所有用户都普遍适用的配置。若使用git config时用--system选项,读写的就是这个文件。
- ~/.gitconfig:用户目录下的配置文件只使用该用户。若使用git config 时用 --global选项,读写的就是这个文件。
- 当前项目中的 .git/config 文件(默认.git文件隐藏):这里的配置仅仅对当前项目有效。
每一个级别的配置都会覆盖上层的相同配置
用户信息配置
配置个人的用户名称和邮件地址:
git config --global user.name 'name'
git config --global user.email 'email'
如果用了--global,那么更改的配置文件就是位于用户目录下的.gitconfig文件,以后你所有的项目都会默认使用这里配置的用户信息。 如果需要在特定的项目中使用其他名字或者邮件,只要去掉--global重新配置既可,新的设定保持在当前项目的.git/config文件里。
文本编辑器 设置Git默认使用的文本编辑器,一般可能会是Vi或者Vim。可以重新设置:
git config --global core.editor emacs
差异分析工具 在解决合并冲突使用哪种差异分析工具。
git config --global merge.tool vimdiff
查看配置信息
$ 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
core.fscache=true
core.symlinks=false
credential.helper=manager
user.naem=xu.jiawei
user.email=xxx
user.name=xx
core.repositoryformatversion=0
core.filemode=false
core.bare=false
core.logallrefupdates=true
core.symlinks=false
core.ignorecase=true
remote.origin.url=xxx
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master
查看 global的配置
$ git config --global --list
user.naem=name
user.email=xx
user.name=xxx
查看某个环境变量的设定值:
$ git config user.name
50318892