1.Git下載:
??訪問Git官網,下載對應作業系統的的安裝包,

??這里筆者是64位機器,選擇如下:

2.Git安裝:
??打開安裝包進行安裝:

??一路next到Finish:

??在CMD中輸入命令git,出現以下界面表示安裝成功:

3.Git配置:
??滑鼠右鍵桌面,選擇Git Bash Here:

??輸入如下命令配置Github賬戶資訊:
1 # 配置用戶名("username"是Github用戶名)
2 git config --global user.name "username"
3 # 配置郵箱("[email protected]"是Github注冊郵箱)
4 git config --global user.email "[email protected]"
??輸入命令git config --global --list查看是否配置成功,

??執行: ssh-keygen -t rsa ,一路回車生成SSH,在C盤你的用戶目錄下可以查看到生成的ssh檔案:

??登錄Github,點擊設定:

??選擇SSH and GPG keys:

??將公鑰( id_rsa.pub)粘貼Key中:

??在Git bash命令視窗中輸入 ssh -T [email protected],出現如下報錯:

??于是在.ssh檔案夾下新建一個檔案config:
??并在記事本中編輯該檔案:
Host github.com
User [email protected] #你的郵箱
Hostname ssh.github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa
Port 443
??再次執行命令 ssh -T [email protected]:輸入yes:

??出現以下回應表示配置成功,

然后發現使用git clone 指令報錯,無法下載專案,在cmd中ping github.com超時,

于是在網路屬性中修改DNS如下:

??在C:\Windows\System32\drivers\etc中的hosts檔案末尾加上140.82.113.3 github.com,

??再次ping github.com,成功ping通,

??重新git clone,成功!

參考:
1. Git的下載、安裝與配置,詳細圖文教程
2. ssh: connect to host github.com port 22: Connection timed out
3. https://stackoverflow.com/questions/63917116/cant-ssh-into-git-pty-allocation-request-failed-on-channel-0
4. Github無法ping通的解決策略
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/543805.html
標籤:其他
