Skip to content

git config:Git配置

git config 命令用于配置 Git 的设置。

常见选项和作用:

  • --global:进行全局配置,适用于当前用户的所有 Git 仓库。
  • --system:进行系统级配置,适用于系统上的所有用户和所有 Git 仓库。

常用场景和实例:

设置用户名

git config --global user.name "Your Name"

这会将您的用户名设置为 Your Name ,以便在提交时标识您的身份。

设置用户邮箱

git config --global user.email "your.email@example.com"

设置默认编辑器: 如果您希望使用特定的编辑器(例如 vim )来编辑提交消息:

git config --global core.editor vim

设置合并策略: 例如设置为 recursive 策略:

git config --global merge.ours.driver true

设置颜色显示: 启用彩色输出,让命令行中的 Git 信息显示更清晰:

git config --global color.ui auto

这些只是 git config 命令的一些常见用法,您可以根据自己的需求进行各种配置。