介绍
- 只需要配置一次,程序升级时会保留配置信息。
- Git 自带一个 git config 的工具来配置, 有三个配置级别
- 系统级配置(git config --system):/etc/gitconfig 文件: 包含系统上每一个用户及他们仓库的通用配置。 如果使用带有 --system 选项的 git config 时,它会从此文件读写配置变量。
- 用户级配置 (git config --global):~/.gitconfig 或 ~/.config/git/config 文件:只针对当前用户。 可以传递 --global 选项让 Git 读写此文件。
- 仓库级配置 (git config):当前使用仓库的 Git 目录中的 config 文件(就是 .git/config):针对该仓库。
- 每一个级别覆盖上一级别,仓库级别会覆盖用户级别,覆盖系统级别
git config --local -e 编辑仓库级别配置文件
git config --global -e 编辑用户级别配置文件
git config --system -e 编辑系统级别配置文件
配置,git config 命令
查看配置
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:/app/devtool/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.process=git-lfs filter-process
filter.lfs.required=true
credential.helper=manager
user.name=yanbin
user.email=yb_860830@163.com
core.repositoryformatversion=0
core.filemode=false
core.bare=false
core.logallrefupdates=true
core.symlinks=false
core.ignorecase=true
remote.origin.url=
remote.origin.fetch=+refs/heads
git config <key>
git config user.name
yanbin
用户信息配置
git config --global user.name "John Doe"
git config --global user.email johndoe@example.com
- –global 选项:全局设置,只需要设置一次,都会用这个信息。
- 当你想针对特定项目使用不同的用户名称与邮件地址时,可以在那个项目目录下运行没有 --global 选项的命令来配置。
- 很多 GUI 工具都会在第一次运行时帮助你配置这些信息。
代理配置
git config --global http.proxy 192.168.4.12:8080
git config --global --unset http.proxy
git config --global --get http.proxygit
git config –global http.proxy http://username:password@10.167.32.133:8080
git命令的别名
- 配置git 命令的别名,可以简化命令操作和记忆, 但是这个不通用,不建议
git config --global alias.co checkout
git config --global alias.br branch
git config --global alias.ci commit
git config --global alias.st status