【问题标题】:Git push failed on forked repository分叉存储库上的 Git 推送失败
【发布时间】:2017-10-17 20:02:18
【问题描述】:

当我尝试将新文件推送到分叉存储库时,'git push' 命令失败。我得到的错误如下: ! [远程拒绝] master -> master(权限被拒绝) 我是分叉存储库的所有者,所以我不确定为什么会收到此错误。我很感激这方面的帮助。 tnx

【问题讨论】:

    标签: git github


    【解决方案1】:

    您确定要推送到正确的遥控器吗?运行命令git remote -v 并确认origin 远程是您有权访问的存储库。如果没有,请推送到您有权访问的遥控器,例如:

    git push -u <remote name> <branch name>
    

    这会将您的本地分支设置为跟踪给定的远程分支,以便git push 默认推送到该分支。如果 push.default 已更改,您可能还需要更改设置。

    【讨论】:

      【解决方案2】:

      试试

      git push origin master
      

      如果这是您第一次推送到这个分叉的存储库

      【讨论】:

      • 您检查过this question 中的修复吗?我认为类似的问题
      【解决方案3】:

      尝试以下步骤

      git config --global --edit

      然后将以下内容添加到conf文件中

      [credential]
        helper = osxkeychain
        useHttpPath = true
      

      【讨论】:

      • 运行 git remote -v 你看到了什么?
      【解决方案4】:

      确保远程是您的存储库:

      $ git remote -v
      origin  https://github.com/octocat/Spoon-Knife.git (fetch)
      origin  https://github.com/octocat/Spoon-Knife.git (push)
      

      如果那不是你的,就这样改:

      $ git remote set-url origin https://github.com/USERNAME/REPOSITORY.git
      $ git remote -v
      origin  https://github.com/USERNAME/REPOSITORY.git (fetch)
      origin  https://github.com/USERNAME/REPOSITORY.git (push)
      

      然后尝试再次推送

      $ git push origin master
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2013-04-13
        • 2013-09-10
        • 2018-03-07
        • 2012-02-22
        • 2012-09-24
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多