【问题标题】:can't able to perform git push, permission denied?无法执行 git push,权限被拒绝?
【发布时间】:2017-08-22 19:06:19
【问题描述】:
  1. 我已经在 github 中创建了一个存储库作为 wordpress 模板。
  2. 我在本地创建了一个 .git 存储库,在那里添加了一些文件,然后提交了它。
  3. 然后我创建了一个远程作为 origin 并将 github 存储库的 url 提供为:

    git remote add origin git@github.com:squalporeover/wordpress-template.git  
    
  4. 现在我想将我的主分支推送到该存储库。我运行了以下命令:

    git push origin master 
    
  5. 但它显示:

    权限被拒绝(公钥)。
    致命:无法从远程存储库读取。

    请确保您拥有正确的访问权限 并且存储库存在。

【问题讨论】:

标签: github git-push


【解决方案1】:

您似乎添加了远程 URL 的 SSH 版本。要使用它,您需要set-up Github with SSH

否则使用 HTTPS 版本的克隆 URL,它将询问您的用户名和密码:

【讨论】:

    【解决方案2】:

    您需要使用 ssh-keygen 来生成 ssh 密钥对。 见:https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/

    在此处找到重复项:Git - Permission denied (publickey)

    【讨论】:

      【解决方案3】:

      这对我有用:

      步骤 1- git remote rm origin

      第二步-select the http option in github

      第 3 步 - 再次运行以下命令

      git 远程添加源https://github.com/yourdirectory/link.git

      git 分支 -M main

      git push -u origin main

      【讨论】:

        猜你喜欢
        • 2016-10-30
        • 1970-01-01
        • 2012-12-29
        • 2013-11-08
        • 2011-09-13
        • 2017-10-21
        • 2013-01-20
        • 2013-10-10
        • 2018-10-24
        相关资源
        最近更新 更多