Git配置操作命令

227 阅读1分钟
  1. 全局配置:

    • git config --global user.name '名字':设置全局用户的名字。
    • git config --global user.email '邮箱':设置全局用户的邮箱。
  2. 当前仓库配置:

    • git config --local user.name '名字':设置当前仓库用户的名字。
    • git config --local user.email '邮箱':设置当前仓库用户的邮箱。
  3. 查看配置信息:

    • git config --global --list:查看全局配置信息。
    • git config --local --list:查看当前仓库配置信息。
  4. 删除配置项:

    • git config --unset --global 要删除的配置项:删除全局配置中的指定项。
    • git config --unset --local 要删除的配置项:删除当前仓库配置中的指定项。

这些配置主要包括用户的姓名和邮箱,用于在提交代码时标识作者。全局配置是针对整个用户帐户的,而当前仓库配置则是针对当前Git仓库的。在多人协作或者使用多个Git仓库时,可能需要设置不同的用户信息以区分它们。