1. 添加 SSH key

一台主机仅需要设置一次

1.1 检查主机是否已经有 SSH key
只需要检查~/.ssh下是否存在 id_rsa.pubid_dsa.pub。若已存在,跳转至步骤3

1.2 生成 SSH key
$ ssh-keygen -t rsa -C "your_email@example.com"

参数含义
-t 指定密钥类型,默认是 rsa ,可以省略。
-C 设置注释文字,比如邮箱。
-f 指定密钥文件存储文件名。
注:参数均可省略,以上代码执行过程中,密码可以设置为默认

1.3 将 SSH key 添加至 github
将步骤1提到的 id_rsa.pubid_dsa.pub 文件中的内容写入以下位置:
github.com -> Settings -> SSH and GPG keys -> New SSH key

1.4 测试
$ ssh -T git@github.com

2. git 初始化
git init

3. 添加远程仓库地址
git remote add origin <remote repositorie address>

4. 正常操作