【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 git@github.com
稍等片刻如果继续报错,如下:
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 YourEmail@qq.com //你的邮箱地址
Hostname ssh.github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa
Port 443
两次ESC键 退出编辑模式,键入 :wq (保存并退出)
- 再次执行
ssh -T git@github.com
出现如下提示,键盘输入yes
即可成功(不要直接按回车键!!!)
$ ssh -T git@github.com
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'.