Git

git config 命令以及配置文件

silverwq
2022-05-25 / 0 评论 / 345 阅读 / 正在检测是否收录...

概述

该命令,用于配置git。

配置文件

三个配置文件,可以手动编辑配置,也可以使用 git config 命令修改

  1. .git/config 文件,作用于当前目录,优先级第一
  2. ~/.gitconfig 文件,作用于特定用户,优先级第二
  3. 安装目录/etc/gitconfig 文件,作用于当前 git 安装,优先级最后

配置文件的语法格式:

  1. 注释使用分号
  2. 配置项 8 个空格,例如
; 别名配置
[alias]
        st = status
        co = checkout
        br = branch
        ci = commit

; 用户名称配置
[user]
        name = wuqiyin
        email = silverwq@qq.com

; http代理配置
[http]
        proxy = socks5://127.0.0.1:1080
[https]
        proxy = socks5://127.0.0.1:1080

命令

git config --list 或者 git config -l,

# 默认是--local级别
git config [--system|--global|--local] -l
git config --list
# 查看具体的某个配置
git config user.name

git config --add

# 默认是--local级别
git config [--system|--global|--local] --add user.name wuqiyin

git config -e

# 默认是--local级别
git config [--system|--global|--local] -e

git config --unset

# 默认是--local级别
git config [--system|--global|--local] --unset user.name
0

评论 (0)

取消