【Git】報錯系列
Qustion1: ssh: connect to host github.com port 22: Connection out
git push時報錯connection timed out
$ git push -u origin master
ssh: connect to host github.com port 22: timed out
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
解決方法:
- 檢查一下SSH是否能夠連接成功,輸入以下命令
ssh -T [email protected]
稍等片刻如果繼續報錯,如下:
ssh: connect to host github.com port 22: Connection z out
- 則繼續輸入以下命令:
$ cd ~/.ssh
$ ls //查看是否存在 id_rsa id_rsa.pun known_hosts 三個文件
id_rsa id_rsa.pub known_hosts themes/
- 新建config文件
$ vim config
i 鍵進入編輯模式,輸入下面內容:
Host github.com
User [email protected] //你的郵箱地址
Hostname ssh.github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa
Port 443
兩次ESC鍵 退出編輯模式,鍵入 :wq (保存並退出)
- 再次執行
ssh -T [email protected]
出現如下提示,鍵盤輸入yes
即可成功(不要直接按回車鍵!!!)
$ ssh -T [email protected]
The authenticity of host '[ssh.github.com]:443 ([192.30.253.122]:443)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '[ssh.github.com]:443,[192.30.253.122]:443' (RSA) to the list of known hosts.
Hi Veal98! You've successfully authenticated, but GitHub does not provide shell access.
Qustion2: On branch master nothing to commit, working tree clean
git commit 的時候報錯
$ commit -m"update README.md"
On branch master
nothing to commit, working tree clean
原因是多次提交,之前因爲push失敗所以提交了好多次導致出現這個報錯
解決方法:
直接git push
$ git push -u origin master
Enumerating objects: 24, done.
Counting objects: 100% (24/24), done.
Delta compression using up to 8 threads.
Compressing objects: 100% (11/11), done.
Writing objects: 100% (14/14), 3.06 KiB | 1.02 MiB/s, done.
Total 14 (delta 6), reused 0 (delta 0)
remote: Resolving deltas: 100% (6/6), completed with 5 local objects.
To github.com:Veal98/Code-Scanner.git
72c5f38..acd9b3b master -> master
Branch 'master' set up to track remote branch 'master' from 'origin'.