github - git 能成功連接,但無法push或pull,求解各位大牛,謝謝!
怪我咯
怪我咯 2017-05-02 09:29:51
0
3
1940

本地建立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)
Peter_Zhu

換成https試試

# 删除旧的origin
git remote remove origin
# 添加https的
git remote add origin https://github.com/timothydsp/learnGit.git
習慣沉默

origin http://github.com/timothydsp/learnGit.git

改成https或ssh地址

巴扎黑
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的錯誤

熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板