简体   繁体   English

分叉存储库上的 Git 推送失败

[英]Git push failed on forked repository

'git push' command failed when I was trying to push a new file to a forked repository.当我尝试将新文件推送到分叉存储库时,“git push”命令失败。 The error I get is as follows: !我得到的错误如下:! [remote rejected] master -> master (permission denied) I am the owner of the forked repository so I am not sure why I get this error. [远程拒绝] master -> master(权限被拒绝)我是分叉存储库的所有者,所以我不确定为什么会出现此错误。 I appreciate help with that.我很感激这方面的帮助。 tnx tnx

Are you sure you're pushing to the right remote?您确定要推到正确的遥控器吗? Run the command git remote -v and confirm that the origin remote is a repository you have access to.运行命令git remote -v并确认origin remote 是您有权访问的存储库。 If not, push to the remote you do have access to like:如果没有,请推送到您有权访问的遥控器,例如:

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

This will set your local branch up to track the given remote branch, so that git push will push to that by default.这会将您的本地分支设置为跟踪给定的远程分支,以便git push将默认推送到该分支。 You may also need to change the setting of push.default if it has been changed.如果push.default已更改,您可能还需要更改它的设置。

Try尝试

git push origin master

if this is the first time you're pushing to this forked repository如果这是您第一次推送到此分叉存储库

Try following steps尝试以下步骤

git config --global --edit git 配置 --global --edit

Then add following to conf file然后在conf文件中加入以下内容

[credential]
  helper = osxkeychain
  useHttpPath = true

Make sure the remote is your repository:确保远程是您的存储库:

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

If that is not yours, change it like this:如果那不是您的,请像这样更改它:

$ 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)

An then try to push again然后尝试再次推动

$ git push origin master

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM