在Windows 上安裝git ,配置 ssh 到 github
| 環(huán)境 | 版本 |
|---|---|
| Windows10 | 1803 |
| git | 2.17.0 |
1. 下載 windows x64 的git 安裝包
2. 安裝git
雙擊git 安裝包

01雙擊安裝包.png
選擇安裝目錄

02選擇安裝目錄.png
選擇安裝選項

03選擇安裝選項.png
是否在開始菜單創(chuàng)建文件夾

04是否在開始菜單創(chuàng)建文件夾.png
選擇git 默認(rèn)的編輯器

05選擇git默認(rèn)編輯器.png
是否在windows cmd中使用 git

06選擇是否在windows cmd中使用git.png
選擇openSSL 包

07選擇使用openSSL包.png
選擇換行符

08選擇換行符.png
選擇git終端模擬器

09選擇git的終端模擬器.png
一些附件選項

10一些附加選項.png
開始安裝

11開始安裝.png
點擊 finish 完成安裝

12點擊 finish 完成安裝.png
在cmd中查看git版本信息

13cmd中查看git版本信息.png
3. 配置 git 賬戶名和郵箱
如果你沒有g(shù)ithub賬號,去注冊一個吧,如何注冊github這里不做介紹。
在cmd中配置賬戶名和郵箱
~$ git config --global user.email "you@example.com"
~$ git config --global uesr.name "you Name"
4. 配置 ssh
配置ssh 可以免去每次 需要輸入密碼的麻煩
01. 生成秘鑰對 (不設(shè)置密碼的話,直接三次回車就生成好了)
~$ ssh-keygen -t rsa -C "you@example.com"
Generating public/private rsa key pair.
Enter file in which to save the key (C:\Users\用戶名/.ssh/id_rsa):
Created directory 'C:\Users\用戶名/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
02. 查看生成的公鑰
使用文本編輯器打開 用戶名/.ssh 文件夾下的 id_rsa.pub 文件
復(fù)制文件內(nèi)容
03. 登錄到github上 ,點擊頭像,然后 Settings -> 左欄點擊 SSH and GPG keys -> 點擊 New SSH key
04. 在title中輸入一個名字,在key 文本域中輸入你的公鑰, 點擊 Add SSH Key
05. 驗證 key是否正常工作
~$ ssh -T git@github.com
Attempts to ssh to github
當(dāng)看到
Hi xxx! You've successfully authenticated, but GitHub does not # provide shell access.
表示 ssh 配置完成。