【问题标题】:Unable to push git local master to remote repository无法将 git local master 推送到远程存储库
【发布时间】:2018-03-14 16:24:48
【问题描述】:

我只是想将我的本地 master 推送到 github 上的远程存储库,但这是不可能的。我已经在我的 github 目录中创建了一个存储库 - 在网站上,我正在开发的应用程序很简单,因为我只在本地 master 上工作 - 没有分支或任何东西。

当我在终端尝试'git push -u origin master'时,回复是:

permission denied (publickey)
fatal: could not read from remote repository

当我尝试“git push”时,响应是:

fatal: the current branch master has no upstream branch. To push the 
current branch and set the remote as upstream, use 'git push --set-
upstream origin master'

但是当我尝试“git push --set-upstream origin master”时,我得到:

Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

我一直在网上尽可能多地阅读这方面的内容,但我无处可去,因此非常感谢一些建议,谢谢:-)

【问题讨论】:

  • 请使用以下命令git remote -v检查您的遥控器。它会向您显示一些这样的网址: origin your_url (fetch) origin your_url (push)
  • 您的 ssh 设置是否正确?或者根本没有设置 shh? Atlassian 有一个很好的指南confluence.atlassian.com/bitbucket/…
  • 在此之后您需要设置您的 ssh。如果您使用 ssh url 克隆存储库,并且如果使用 https url 克隆存储库,则需要在每个操作(拉取。推送和获取)中输入密码。
  • 谢谢你们两个:-)

标签: git repository git-remote


【解决方案1】:

您可能没有从您创建的存储库中读取或写入的权限。您需要生成一个新的 SSH 密钥并将公钥添加到您的 Github 帐户。如果您不知道如何操作,请参阅https://help.github.com/articles/connecting-to-github-with-ssh/

【讨论】:

    【解决方案2】:

    -- 如果要更新分支--

    git checkout master
    
    git pull origin master
    
    git checkout YOUR-BRANCH
    
    git rebase master
    

    ——如果你想提交你的代码——

    git add -A
    
    git commit -m "any comment"
    
    git push origin YOUR-BRANCH
    
    git checkout master
    
    git pull origin master
    
    git checkout YOUR-BRANCH
    
    git rebase master
    

    最后

    git push origin YOUR BRANCH
    

    在你提交合并请求之后

    【讨论】:

      猜你喜欢
      • 2018-06-24
      • 2010-10-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-07-27
      • 2021-06-07
      • 2013-01-27
      相关资源
      最近更新 更多