git push = 上的错误 [远程拒绝] master -> master(预接收钩拒绝)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21407962/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Error on git push = ! [remote rejected] master -> master (pre-receive hook declined)
提问by paul
I think, it's a different issue than this(remote rejected master -> master (pre-receive hook declined)), and many people are facing same issue, So I am posting a new here.
我认为,这是一个不同的问题(远程拒绝主 -> 主(预接收钩拒绝)),很多人都面临同样的问题,所以我在这里发布一个新的。
My friend added me on bitbucket.org as admin, so that I can help on his project. So, I wanted to start by taking a pull of latest code on my local.
我的朋友在 bitbucket.org 上将我添加为管理员,以便我可以帮助他的项目。所以,我想从我本地的最新代码开始。
Steps I followed:
我遵循的步骤:
- Goto empty folder
git init
git remote -v
(this gives nothing)git remote add origin <path to git repo>
git remote add master <path to git repo>
git remote -v
(this show both with fetch and push in brackets)git fetch origin master
git pull origin master
(I have latest code now, all files and folders)touch test
(lets test a "test" commit)git status
git add .
git commit -m "testing, first commit"
git push origin master
- 转到空文件夹
git init
git remote -v
(这什么也没给)git remote add origin <path to git repo>
git remote add master <path to git repo>
git remote -v
(这显示了 fetch 和 push 在括号中)git fetch origin master
git pull origin master
(我现在有最新的代码,所有文件和文件夹)touch test
(让我们测试一个“测试”提交)git status
git add .
git commit -m "testing, first commit"
git push origin master
error:
错误:
Counting objects: 4, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 274 bytes | 0 bytes/s, done.
Total 3 (delta 1), reused 0 (delta 0)
remote: permission denied to update branch master
To '<repo path>'
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to '<repo path>'
回答by First Zero
It looks like the branch management (one of the admin settings) in bitbucket has been configured to only allow certain people to push directly to master.
看起来 bitbucket 中的分支管理(管理设置之一)已配置为仅允许某些人直接推送到 master。
Try creating a branch - git checkout -b test
, create your test commit and push git push origin test:test
. You can always cleanly delete this branch once you have completed the test.
尝试创建一个分支 -git checkout -b test
创建您的测试提交并推送git push origin test:test
。完成测试后,您始终可以干净地删除此分支。
The other option (probably best agreeing with whoever set this up) is you go to bitbucket
and head to admin, branch management and remove master
be to limited. cf - https://confluence.atlassian.com/display/BITBUCKET/Branch+management
另一种选择(可能最好与设置此设置的人达成一致)是您去bitbucket
管理,分支管理并删除master
限制。cf - https://confluence.atlassian.com/display/BITBUCKET/Branch+management
回答by Euripides Georgantzos
Just reporting another case leading to the specified error. If the Bitbucket repository size reaches 2 GB, Bitbucket itself restricts the repository to read-only access. When that happens, contributors with read/write permissions are not able to push and get the "pre-receive hook declined" error.
只是报告导致指定错误的另一个案例。如果 Bitbucket 存储库大小达到 2 GB,Bitbucket 本身会将存储库限制为只读访问。发生这种情况时,具有读/写权限的贡献者无法推送并收到“预接收挂钩被拒绝”错误。
I also found these documents from Atlassian: https://blog.bitbucket.org/2014/05/30/repository-size-limits/https://confluence.atlassian.com/bitbucket/reduce-repository-size-321848262.html
我还从 Atlassian 找到了这些文件:https: //blog.bitbucket.org/2014/05/30/repository-size-limits/ https://confluence.atlassian.com/bitbucket/reduce-repository-size-321848262。 html
Links include a guide on how to restore the repo back to full functionality
链接包括有关如何将 repo 恢复到完整功能的指南
回答by Savad KP
I think package setuptools/distribute is listed in requirements.txt. Please remove the same.
我认为包 setuptools/distribute 列在 requirements.txt 中。请删除相同的。
回答by Shina
What worked for me was:
对我有用的是:
- Created a new branch locally
- Bitbucket -> Settings -> Repository details = changed default branch (e.g to prod)
- Bitbucket -> Branches -> delete master branch (you can do this without step 2)
- Then push your locally created branch (e.g master)
- Bitbucket -> Settings -> Repository details = changed default branch (e.g to master)
- 在本地创建了一个新分支
- Bitbucket -> Settings -> Repository details = 更改的默认分支(例如到 prod)
- Bitbucket -> 分支 -> 删除主分支(你可以不用步骤 2)
- 然后推送您本地创建的分支(例如 master)
- Bitbucket -> Settings -> Repository details = 更改的默认分支(例如到 master)
回答by Kamil Kie?czewski
I have better solution on Bitbucket: If you are admin go to Repo >Settings >Limit Pushes section, and in "Branch name" put 'master', and in "..search... user" put your user name - then push "ADD" - and you are done :)
我在 Bitbucket 上有更好的解决方案:如果您是管理员,请转到 Repo >Settings >Limit Pushes 部分,并在“Branch name”中输入“master”,并在“..search... user”中输入您的用户名 - 然后 push “添加” - 你就完成了:)
回答by Abdul Manan
The same issue with me on gitlab, I asked the repo owner to grand me maintainer
role and the issue fixed.
我在 gitlab 上遇到了同样的问题,我要求 repo 所有者授予我maintainer
角色并解决了问题。