github - git 能成功连接,但是无法push或者pull,求解各位大牛,谢谢!

 手机用户2502875023 发布于 2022-10-26 12:21

本地建立git后,代码提交到版本库后。准备上传到github。
建立路径:

Birdy-2:learnGit birdy$ git remote add origin http://github.com/timothydsp/learnGit.git
Birdy-2:learnGit birdy$ git push -u origin master
fatal: unable to access 'http://github.com/timothydsp/learnGit.git/': Recv failure: Connection reset by peer

这里开始报错,不能连接
然后我尝试看链接地址有没有问题:

Birdy-2:learnGit birdy$ git remote add origin http://github.com/timothydsp/learnGit.git
fatal: remote origin already exists.

发现没有问题,尝试连接github:

Birdy-2:learnGit birdy$ ssh -T git@github.com
Hi timothysdp! You've successfully authenticated, but GitHub does not provide shell access.

能成功连接,再查看本地公钥是否存在:

Birdy-2:learnGit birdy$ cd ~/.ssh
Birdy-2:.ssh birdy$ ls
id_rsa        id_rsa.pub    known_hosts

检查线上公钥是否一样:

Birdy-2:learnGit birdy$ pbcopy <~/.ssh/id_rsa.pub

也应该没有问题吧?????
到这里:

Birdy-2:learnGit birdy$ ssh -T git@github.com
Hi timothysdp! You've successfully authenticated, but GitHub does not provide shell access.

这样一圈下来为什么不能push,不能pull?

这里线上一能看到我的项目。

求各位前辈教教我,哪里出了错?

有大哥提到更换成HTTPS;或者ssh

Birdy-2:learnGit birdy$ git remote add origin https://github.com/timothysdp/learnGit.git
fatal: remote origin already exists.
Birdy-2:learnGit birdy$ git remote add origin git@github.com:timothysdp/learnGit.git
fatal: remote origin already exists.
Birdy-2:learnGit birdy$ git push -u origin master
fatal: unable to access 'http://github.com/timothydsp/learnGit.git/': Recv failure: Connection reset by peer

貌似还是不行~~

3 个回答
  • Birdy-2:learnGit birdy$ git remote rm origin
    Birdy-2:learnGit birdy$ git remote add origin git@github.com:timothysdp/learnGit.git
    Birdy-2:learnGit birdy$ git push -u origin master
    Counting objects: 12, done.
    Delta compression using up to 8 threads.
    Compressing objects: 100% (6/6), done.
    Writing objects: 100% (12/12), 924 bytes | 0 bytes/s, done.
    Total 12 (delta 0), reused 0 (delta 0)
    To git@github.com:timothysdp/learnGit.git
    • [new branch] master -> master

      Branch master set up to track remote branch master from origin.
      

    可以了,看来是我没注意http和https的错误

    2022-10-27 00:47 回答
  • origin http://github.com/timothydsp/learnGit.git

    改成https或者ssh地址

    2022-10-27 00:47 回答
  • 换成https试试

    # 删除旧的origin
    git remote remove origin
    # 添加https的
    git remote add origin https://github.com/timothydsp/learnGit.git
    2022-10-27 00:47 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有