问题一、

Connection closed by UNKNOWN port 65535

设置config文件为

Host github.com
Hostname ssh.github.com
Port 443
User git

问题二、

ERROR: Repository not found.fatal: Could not read from remote repository.Please make sure you have the correct access rightsand the repository exists.

解决:

1.先检查ssh连接是否有效:ssh -T git@github.com,看返回的仓库对不对的上,如果对不上就重新连接,一般会是 hi xxxxxxx

2.然后检查dai li是否有效,如果是pycharm需要在pycharm设置dai li 

3.如果是ssh连接在pycharm的github的设置页面左下角勾上使用ssh

4.最后如果发现如何检查都错误,可能是远程仓库缓存异常(比如尝试了很多次连接仓库)
使用git remote remove origin命令删除远程连接
然后重新git remote add origin git@github.com:XXX/XXX

问题三、

Updates were rejected because the remote contains work that you do not have locally

方法1.注意以下方法本地仓库的当前代码会被替代,如果是第一次提交不建议用

  • 如果 git pull --rebase 或其他操作导致本地代码丢失:
    git reflog
    结果类似
    a1b2c3d (HEAD -> main) HEAD@{0}: pull --rebase: checkout origin/main
    e4f5g6h HEAD@{1}: commit: 本地修改1
    i7j8k9l HEAD@{2}: commit: 本地修改2

  • 找到丢失代码对应的 commit hash:
    git reset --hard e4f5g6h

git pull origin main --rebase
# 解决冲突后
git push -u origin main

方法2.强制推送(覆盖远程内容,慎用)
git push -u origin main --force

问题四、

具体报错没记录上,总之有可能是使用了http连接,github的教程那边用的是http,在连接仓库的时候要用ssh:
git remote set-url origin git@github.com:xxxxxx

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐