跳到主要内容

安装

window

window 可以直接 下载 git 软件 进行下载。

Linux

sudo yum install git

Mac

在 Mac 上,如果安装了 Xcode ,会默认安装了 git 。

可适用 git --version 查看版本来校验是否安装成功。

config

在安装完 git 后,第一件事就是设置名称和邮箱地址

  • /etc/gitconfig 文件:系统中对所有用户都普遍适用的配置。若使用 git config 时用 --system 选项,读写的就是这个文件

  • ~/.gitconfig 文件:用户目录下的配置文件只适用于该用户。若使用 git config 时用 --global 选项,读写的就是这个文件

  • 当前项目的 Git 目录中的配置文件(也就是工作目录中的 .git/config 文件):这里的配置仅仅针对当前项目有效。每一个级别的配置都会覆盖上层的相同配置,所以 .git/config 里的配置会覆盖 /etc/gitconfig 中的同名变量。

  • 配置问价储存位置

  • /ect/gitconfig 包含了适用系统的用户和所有库的值。

git config --system  #  明确读写该文件

  • ~/.gitconfig 文件,用户定义的特定文件 git config --global
  • ./gitconfig 当前库的配置

用户信息

git config --global user.name "lmssee"  #  设置姓名
git config --global user.email "lmssee@outlook.com" # 设置 email

重置

#  使用 unset 命令重置已设置项
git config --unset --global user.email

编辑器

默认编辑器时 Vim ,若想使用其他的编辑器,可以:

git config --global core.editor {编辑器的名字}

git 接受 kdiff3、 tkdiff 、 xxdiff 、 emerge 、 vimdiff 、 gvimdiff 、 ecmerge 、 opendiff 等有效的合并工具,也可以接受一个客户端的工具。

分析工具

git config --global merge.tool {分析工具的名字}

配置列表

git config --list