一、安装git

1、首选需要安装 Homebrew
mac安装Homebrew教程
2、执行一条命令即可

  1. brew install git

3、查看下 git 版本

  1. git --version

二、常用命令

1、设置提交人名字

  1. 查看提交人名字和邮箱

    1. superking@wangchaodeMacBook-Pro shardingsphere % git config user.name
    2. supkingx
    3. superking@wangchaodeMacBook-Pro shardingsphere % git config user.email
    4. supkingx@gmail.com
  2. 设置全局提交人名字和邮箱

    1. git config --global user.email "supkingx@gmail.com"
    2. git config --global user.name "supkingx"
  3. 单独设置当前工程的提交人和名字。

打开工程目录下的隐藏文件 .git 下面的文件 config,在里面配置如下信息。

  1. [user]
  2. name = wangchao
  3. email = wc262944@ncarzone.com

文件位置如下》
image.png

三、使用SSH拉取代码

git config —global user.name “your_name”
git config —global user.email “your_email”
ssh-keygen -t rsa -C “YOUR_EMAIL@YOUREMAIL.COM”

将文件 /Users/用户名/.ssh/id_rsa.pub 打开
并将里面的公钥复制到github即可