【问题标题】:fatal: unable to connect to github.com: github.com[0: 140.82.121.4]: errno=Unknown error致命:无法连接到 github.com:github.com[0:140.82.121.4]:errno=未知错误
【发布时间】:2022-07-03 20:07:53
【问题描述】:

每次执行 git push 时,我的 git accout 都会出现问题 enter image description here

我发现我正在使用 ssh url enter image description here

我尝试使用 git config --global url.https://github.com/.insteadOf git://github.com/git config --global url."https://".insteadOf git:// 返回 https url 但它不会改变enter image description here
我尝试了许多解决方案,例如手动配置配置文件,但没有任何效果

【问题讨论】:

    标签: git git-push git-remote


    【解决方案1】:

    要将gitssh 一起使用,需要使用不同的url 语法,使用git@<url> 作为url。 根据您的屏幕截图,该网址很可能看起来像这样

    git@github.com:ahlemtbini/blog_web.git
    

    您可以使用以下命令更改它

    git remote set-url origin git@github.com:ahlemtbini/blog_web.git
    

    如果您使用的是github,我建议您始终使用该存储库github-页面上code-按钮下列出的URL。 More information here

    有关 git 使用的协议的更多信息,请阅读有关 git server protocols 的页面。

    【讨论】:

    【解决方案2】:

    所以我认为这里发生了一些事情:

    1. 您的第一个屏幕截图中的错误看起来可能是由于使用不执行任何类型身份验证/授权的普通 git:// 协议克隆了存储库。这意味着你可以git pull,但你不能git push

    2. 如果你想更新你的 git 配置以在推送时自动使用https,你可以在你的 gitconfig 中添加这样的内容:

    [url "https://github.com/"]
        pushInsteadOf = git://github.com/
    
    1. 或者,如果您想使用 SSH 而不是 git://https:// 协议(并将您的公钥上传到您的 GH 帐户),您可以添加
    [url "git@github.com:"]
        pushInsteadOf = git://github.com/
        pushInsteadOf = https://github.com/
    
    

    【讨论】:

    • GitHub 也不再支持git:// 协议,因此最好停止使用此类 URL。 ?
    猜你喜欢
    • 2023-01-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-15
    • 1970-01-01
    • 2015-06-12
    • 1970-01-01
    相关资源
    最近更新 更多