Git 基本配置

git 配置文件路径

  • Windows: ~/.gitconfig
  • Linux: /etc/gitconfig (系统级别)、~/.gitconfig~/.config/git/config (用户级别)
  • 针对于项目的配置: 项目路径/.git/config

配置优先级: 项目级 > 用户级 > 系统级

  • 使用参数 --system 配置系统级配置
  • 使用参数 --global 配置用户级配置
  • 直接使用 git config 配置项目级配置

配置用户名和 Email

第一次使用 git, 需要修改提交的用户名和 Email, 否则会报以下提示:

Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly. Run the
following command and follow the instructions in your editor to edit
your configuration file:
    git config --global --edit
After doing this, you may fix the identity used for this commit with:
    git commit --amend --reset-author


$ git config --global <Your Name>
$ git config --global <>


$ git commit --amend --author='Your Name <>'


  email =
  name = quanzaiyu
  postBuffer = 1048576000

要查看当前配置, 使用:

$ git config --list

获取某个指定的配置, 比如查看用户名:

$ git config

MIT Licensed | Copyright © 2018-present 滇ICP备16006294号

Design by Quanzaiyu | Power by VuePress