安装git

可以登录git官网下载安装 Git 官方文档地址: https://git-scm.com/book/zh/v2 macOS 平台 Git 下载地址: https://git-scm.com/download/mac Windows 平台 Git 下载地址: https://git-scm.com/download/win Linux 平台 Git 下载地址: https://git-scm.com/download/linux 检查安装结果:下载好之后按照提示进行安装,安装完毕后在终端使用git --version命令,看是否返回 git 的版本

最小配置

安装好git后需要进行最小配置(设置用户名和邮箱)才可以正常使用git 配置user.name和user.email git config --global user.name 'your_name' $ git config --global user.email 'your_email@domain.com'

config 的三个作⽤域

config默认参数为local git config --local(只对当前仓库有效,且需要在仓库目录下进行设置) git config --global(global对登录⽤户所有仓库有效(常用)) git config --system(对系统的所有⽤户有效) 显示 config 的配置:加 --list,例如git config --list --local 清除 config 的配置:加 --unset,例如git config --unset --local user.name 优先级:local > global > system(如在global配置中包含A仓库,并且A仓库配置了local,则相关操作会使用local配置的信息执行)