使用错误用户和预接收钩子的 Git 推送被拒绝
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/39360527/
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
Git push with wrong user and pre-receive hook declined
提问by liu shuai
I found it is different from what others met. I have two problems:
我发现它与其他人遇到的不同。我有两个问题:
- Git push with the user named 'v3' (this user is not mine). The command:
- 使用名为“v3”的用户(此用户不是我的)进行 Git 推送。命令:
but Git push with the user named 'v3'.
但是使用名为“v3”的用户进行 Git 推送。
- After I removed the 'push' right of user 'v3', it told me 'pre-receive hook declined' when I ran
git push
- 删除用户“v3”的“推送”权限后,运行时它告诉我“预接收挂钩被拒绝”
git push
Error message:
错误信息:
Total 9 (delta 4), reused 0 (delta 0)
remote: GitLab: You don't have permission
error: failed to push some refs to 'http://gitlab.zank.mobi/zank/zank_live_service.git'
To http://gitlab.zank.mobi/zank/zank_live_service.git
! refs/heads/develop:refs/heads/develop [remote rejected] (pre-receive hook declined)
回答by Shivam Mathur
Your can do an interactive rebase to change the commit author.
您可以执行交互式变基来更改提交作者。
git rebase -i {commit hash here}
Then change action in front of commit to edit and save. After saving use following command to change author and complete rebase.
然后更改提交前的操作以进行编辑和保存。保存后使用以下命令更改作者并完成变基。
git commit --amend --author="New Author Name <[email protected]>"
git rebase --continue
Then you can check your commits using git log
. The author in the said commit should be the new author.
然后你可以使用git log
. 所述提交中的作者应该是新作者。
When you push use git push --force-with-lease
当你推动使用 git push --force-with-lease
Update
更新
"pre-receive hook declined" - This error might be due to reasons mentioned in answers below.
“预接收挂钩被拒绝” - 此错误可能是由于以下答案中提到的原因造成的。
There is a script hooked which checks if the commits being pushed are good enough, if not then it declines it and gives this error. So check git log
to get the commits you are pushing and check here if any commits are from the user who does not have permission or there is some code in one of the commits which triggers that error.
有一个挂钩的脚本,它检查被推送的提交是否足够好,如果不是,则拒绝它并给出此错误。因此,请检查git log
以获取您正在推送的提交,并在此处检查是否有任何提交来自没有权限的用户,或者其中一个提交中是否有一些代码触发了该错误。