• git config --list [--system|--global|--local] 显示当前配置
  • git config [--system|--global|--local] <key> <value> 设置参数
  • git config -e [--system|--global|--local] 编辑配置
  • git config --global alias.<alias-name> "<git-command>" 创建别名
  • git <alias-name> <arguments> 使用别名
  • git config --global --unset <key> 移除单个变量
  • git config --global --unset-all <key> 移除所有变量
  • 设置例子
    # 设定身份
    git config --global user.name "cheatsheet"
    git config --global user.email "cheatsheet@cheatsheet.wang"
    # 首选编辑器
    git config --global core.editor vim
    # 设置自动命令行着色
    git config --global color.ui auto
    #长期保存账号和密码
    git config --global credential.helper store
    
  • 别名使用例子
    # 设置别名
    git config --global alias.co checkout
    #使用别名
    git co master
    
  • 文件配置
    #本地库文件配置
    <repo>/.git/config
    #系统登录用户全局配置
    ~/.gitconfig
    #系统全局配置
    /etc/gitconfig