Git-安装和配置

环境:

  • Windows 10

安装Git

  1. 从官网http://www.git-scm.com/download/,下载Git安装包
  2. 一路Next
  3. 询问使用何种命令行工具时,选择Use Git from Git Bash only
  4. git/bin添加进环境变量

配置Git

  1. 配置user_nameuser_email

    1
    2
    git config --global user.name "用户名"
    git config --global user.email "邮箱"
  2. 生成git的公钥和私钥,会将你的rsa key生成到目录C:/Users/用户名/.ssh/id_rsa

1
ssh-keygen -t rsa -C "邮箱"
  1. 将公钥添加到github账号中

    • settings->SSH and GPG keys->New SSH key->将刚才生成的id_rsa.pub粘进去

    • 进行测试

      1
      2
      ssh -T git@github.com
      # 并且输入yes回车