[记录2]Git初始化及Github设置SSH

99 阅读1分钟

安装

网上有详细流程

初始化设置

$ git config --list 查看配置
$ git config --global user.name "jessie" 设置用户名
$ git config --global user.email "xxx@163.com" 设置邮箱
$ git config user.name 具体查看某一项配置
$ git config --global color.ui auto 可以提高命令的可读性

设置SSH Key

git中

$ ssh-keygen -t rsa -C "xxx.@163.com"
Generating public/private rsa key pair. Enter file in which to save the key (/Users/your_user_directory/.ssh/id_rsa): 按回车键
Enter passphrase (empty for no passphrase): 输入密码
Enter same passphrase again: 重复输入密码
此时就设置好了
id_rsa 文件是私有密钥,id_rsa.pub 是公开密钥

打开GitHub,设置 SSH Key

设置中找到SSH
填写title
复制公钥内容 --- 公钥内容从git中获取

git

$ cat ~/.ssh/id_rsa.pub 获取到公钥内容
将内容复制到GitHub上
此时ssh就设置成功,你的邮箱将会收到一封ssh设置成功的邮件。

测试一下

git

$ ssh -T git@github.com
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
会遇到让你输入密码的情况,那你就将密码输入进去
Hi Jjesssie! You've successfully authenticated, but GitHub does not provide shell access.

成功啦~