初始设置
前提条件 - 电脑安装了 Git - 拥有一个 GitHub 账号
- 设置姓名和邮箱地址 之后可以在 .gitconfig 文件中看到这些信息
1
2git config --global user.name "用户名"
git config --global user.email "邮箱地址"
建议git config --global color.ui auto
配置 SSH key
1
2
3
4
5$ ssh-keygen -t rsa -C "邮箱地址"
Generating public/private rsa key pair.
Enter file in which to save the key (~/.ssh/id_rsa): 按回车
Enter passphrase (empty for no passphrase): 输入密码
Enter same passphrase again: 再次输入密码查看公钥内容
1
2$ cat ~/.ssh/id_rsa.pub
ssh-rsa 公钥内容 邮箱地址连接 GitHub 在 GitHub 的 Setting > SSH Keys 将公钥内容(以 ssh-rsa 打头)添加进去
测试是否已经连接成功
1
2
3$ ssh -T git@github.com
Enter passphrase for key 'C:\Users\WANG/.ssh/id_rsa': 输入密码
Hi You've successfully authenticated, but GitHub does not provide shell access.