Git環境搭建以及上傳到GitHub全文記錄

1.百度搜索下載git,官網可能很慢,我在百度軟件裏面下載的。固然可能不是最新版本。一路回車安裝就好。git

 

2.設置本機git的用戶名和郵箱地址github

查看當前電腦是否設置了用戶名稱
$ git config user.name
若是沒有會返回空

設置當前用戶名稱
$ git config --global user.name "Gabriel_wei"

查看當前電腦用戶名是否 設置成功
$ git config use.name

設置郵箱地址
$ git config --global user.email "123@123.com

查看當前的全部配置項

  $ git config --listshell

 

3.設置一個ssh連接到咱們的GitHubbash

3.1查看之前是否生成過sshdom

$ cd ~/.ssh

若是沒有會返回空
bash: cd: /c/Users/Administrator/.ssh: No such file or directory

3.2生成SSHssh

注意-C後面沒有空格
$  ssh-keygen  -t   rsa   -C"123@123.com"

一路回車就行,他會返回
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/Administrator/.ssh/id_rsa):
Created directory '/c/Users/Administrator/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/Administrator/.ssh/id_rsa.
Your public key has been saved in /c/Users/Administrator/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:3zie8yG2e3QNBnqUVod/cZBm3tcKKapEPs1FFfl/RPo 123@123.com
The key's randomart image is:
+---[RSA 2048]----+
|           .o+ oo|
|          . = *o.|
|         . o O =+|
|      .   + + *.F|
|     o oSo o o **|
|      + +. .  ..E|
|     . o  . .o++o|
|      .     ..o+=|
|             oo o|
+----[SHA256]-----+

3.3登陸GitHub,將咱們生成的祕鑰填入GitHub。在頭像那裏點擊選擇setting(設置),進入以下頁面




3.4祕鑰的存放地址ide

我得路徑是這個
C:\Users\Administrator\.ssh

裏面有兩個文件,一個id_rsa,一個id_rsa.pub,後面這個就是咱們鏈接GitHub的ssh,用記事本打開復制粘貼就行。

3.5接着3.4的步驟來,點擊New SSH key,如圖所示,輸入3.4的祕鑰就好測試


3.6測試一下是否能夠連接到GitHubspa

輸入
$ ssh git@github.com

正常狀況下面會這麼回覆
The authenticity of host 'github.com (192.30.253.113)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGdafdpRomTxdCARLviKw6E5SY8.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,192.30.253.113' (RSA) to the list of known hosts.
PTY allocation request failed on channel 0
Hi Gabrielkaliboy! You've successfully authenticated, but GitHub does not provide shell access.
Connection to github.com closed.

自此,咱們成功新建了一個SSH,而且連接到了GitHub。code

相關文章
相關標籤/搜索