关于github:Mac使用GitHub

6次阅读

共计 1786 个字符,预计需要花费 5 分钟才能阅读完成。

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.com
The 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

各种大杂烩,侵删~

正文完
 0