【发布时间】:2018-06-26 13:19:44
【问题描述】:
如何查看我可以推送到哪些分支?我刚刚接受了管理员的邀请,加入了一个 GitHub 项目,并切换到了我的代码所在的分支
localhost:myproject davea$ git checkout unit_tests_20180116
Switched to branch 'unit_tests_20180116'
但是当我尝试推送我的更改时,我收到一条错误消息,提示我无权推送到分支。
localhost:myproject davea$ git push origin master
Username for 'https://github.com': myusername
Password for 'https://myusername@github.com':
Counting objects: 54, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (48/48), done.
Writing objects: 100% (54/54), 101.02 KiB | 0 bytes/s, done.
Total 54 (delta 12), reused 0 (delta 0)
remote: Resolving deltas: 100% (12/12), completed with 5 local objects.
remote: error: GH006: Protected branch update failed for refs/heads/master.
remote: error: You're not authorized to push to this branch. Visit https://help.github.com/articles/about-protected-branches/ for more information.
To https://github.com/CaravanTransit/myproject.git
! [remote rejected] master -> master (protected branch hook declined)
error: failed to push some refs to 'https://github.com/CaravanTransit/myproject.git'
如何确定我可以推送到哪些分支?
编辑: 以下是针对给定输出列出的内容。但是,虽然“master”出现在远程列表中,但我仍然无法推送到它。
localhost:myproject davea$ git remote show origin
* remote origin
Fetch URL: https://github.com/CaravanTransit/myproject.git
Push URL: https://github.com/CaravanTransit/myproject.git
HEAD branch: master
Remote branches:
adding-tests tracked
admin-panel-fixes tracked
flexbox tracked
flexbox2 tracked
master tracked
rename-to-caravan tracked
Local branches configured for 'git pull':
adding-tests merges with remote adding-tests
master merges with remote master
Local refs configured for 'git push':
adding-tests pushes to adding-tests (up to date)
master pushes to master (fast-forwardable)
【问题讨论】:
-
也许我错过了什么,但为什么会这样?这个问题是是否有人可以推送到现有的分支,我想知道我有资格推送到哪些分支。
-
问题(如该答案中突出显示的那样)是您只能通过尝试推动某些东西并使其失败来知道 - 他们正在尝试“试运行”,但由于这没有改变,它实际上并没有测试写作能力。使用 git 可以通过多种方式控制授权 - 除非您知道那是什么(文件权限、网络服务器、提交挂钩等)并且有办法查询它,否则您不尝试就无法知道。
-
好的,所以实际上没有办法按照我的要求去做。 (?) 听起来这是您应该提交的答案。
-
您是否尝试查看错误消息告诉您查看的内容,关于受保护分支的 github 页面?
标签: github branch remote-access