1.装置Git

在命令行输出 brew install git

2.查看是否有SSH keys

①输出 cd ~/.ssh
②输出 ls 查看文件夹内详情,如果看到以下三个文件:

id_rsa id_rsa.pub known_hosts

那么就进行备份:
输出 mkdir key_backup 创立一个新文件夹用于保留旧的id_rsa
输出 cp id_rsa* key_backup 挪动旧的id_rsa至key_backup
输出 rm id_rsa* 删除旧的id_rsa

3.创立新的

①输出 ssh-keygen -t rsa -C "youremail@youremail.com" 留神邮箱前后要输出"",显示以下:

Generating public/private rsa key pair.Enter file in which to save the key (/Users/username/.ssh/id_rsa): 

②按回车enter,显示以下:

Enter passphrase (empty for no passphrase): 

③再按回车enter,显示以下:

Enter same passphrase again: 

④再按回车enter,显示以下:

Your identification has been saved in /Users/username/.ssh/id_rsa.Your public key has been saved in /Users/username/.ssh/id_rsa.pub.The key fingerprint is:SHA256:******************************************* youremail@youremail.comThe key's randomart image is:+---[RSA 3072]----+|      E          ||     o o .       ||      + . . .    ||     o     . ooo.||      o.S= ooo.=+||     o o= O.o . *||      +o.O =.= ..||     o..= Bo= .  ||    .o+. oo+.    |+----[SHA256]-----+

⑤在GitHub上增加你的SSH key


Title:xxxxxxxx@mail.com
Key:输出 cat id_rsa.pub 关上生成的id_rsa.pub文件,全副都复制粘贴过去。
就实现啦

4.验证

①输出 ssh -T git@github.com ,显示以下:

The authenticity of host 'github.com (13.250.177.223)' can't be established.RSA key fingerprint is SHA256:*******************************************.Are you sure you want to continue connecting (yes/no/[fingerprint])?

②输出 yes ,显示以下:

Warning: Permanently added 'github.com,13.250.177.223' (RSA) to the list of known hosts.

5.设置用户名和邮箱

输出 git config --global user.name "your name"
输出 git config --global user.email "xxxxx@163.com"

6.Create a new repository


填写Repository name,即可实现创立。

7.应用Git在本地创立一个我的项目

①输出 mkdir ~/HelloWorld 创立一个我的项目叫HelloWorld
②输出 cd ~/HelloWorld 进入这个文件夹
③输出 git init 初始化这个文件夹,显示以下:

已初始化空的 Git 仓库于 /Users/username/HelloWorld/.git/

④输出 touch README
⑤输出 git add README.md 更新README文件
⑥输出 git commit -m "first commit" 提交更新,并正文信息“first commit”

8.将本地的PUSH到GitHub上

①输出 git remote add origin https://github.com/xxxxx/xxxxx.git 即下图第二个框内容

②输出 git push -u origin master master是你要推送到的分支

9.从GitHub中PULL到本地

输出 git pull origin

各种大杂烩,侵删~