GIT(05)配置

介绍


  • 只需要配置一次,程序升级时会保留配置信息。
  • 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/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master
branch.bthss_V3.0.4.remote=origin
branch.bthss_V3.0.4.merge=refs/heads/bthss_V3.0.4
  • 查看某项配置
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 commit 时,只需要输入 git ci
git config --global alias.st status
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值