git 中的错误:您只能在此存储库中推送自己的提交
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/52886362/
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 in git: You can only push your own commits in this repository
提问by Oleg
Yesterday I started to recieve errors when trying to push my commit to repo, how to fix it? And I am not admin of this repo.
昨天我在尝试将我的提交推送到 repo 时开始收到错误,如何修复它?我不是这个 repo 的管理员。
remote: You can only push your own commits in this repository
remote: Commit commitName was committed by <myName> <[email protected]>
To ssh://bitbucket.awg.ru/repo
! [remote rejected] branchName -> branchName (pre-receive hook declined)
error: failed to push some refs to 'ssh://[email protected]/repo'
Update
更新
Thanks everybody, the problem is solved. The problem was on the Bitbucket side, the admininstrator changed some options. Now everything is OK.
谢谢大家,问题解决了。问题出在 Bitbucket 方面,管理员更改了一些选项。现在一切正常。
回答by Oleg
Thanks everybody, problem is solved. Problem was on Bitbucket side, administrator changed some options. Now everything is OK.
谢谢大家,问题解决了。问题出在 Bitbucket 方面,管理员更改了一些选项。现在一切正常。
UPDATE
更新
As per @Oleg who asked the question. The problem in general happens because of a Bitbucket hook. This hook will reject any push that contains a commit not committed by the user who pushes to the server.
根据提出问题的@Oleg。问题通常是由于 Bitbucket 挂钩而发生的。此挂钩将拒绝任何包含未由推送到服务器的用户提交的提交的推送。
To solve the issue:
要解决这个问题:
- You must have Admin access to the repository in Bitbucket server
- Go to the repository in the server
- Then ? Repository settingsin the sidebar
- Select Hooks
- Disable Verify Committerhook
- You are done
- 您必须对 Bitbucket 服务器中的存储库具有管理员访问权限
- 转到服务器中的存储库
- 然后?侧边栏中的存储库设置
- 选择挂钩
- 禁用验证提交者挂钩
- 你完成了
回答by Manish R
You will need to set your identify before pushing it to bitbucket
在将其推送到 bitbucket 之前,您需要设置您的身份
git config --global user.email "Your Email"
git config --global user.name "Your Name"
git push origin <branch-name>
回答by eeijlar
回答by Neupane
Go to your repo browser and check what your username and email is on your profile ( the top right corner)
In git bash update your detail as per your git web profile git config --global user.email "[email protected]" git config --global user.name "USERNAME"
You will need to undo the commit and then redo it after you changes you user detail in step 2
Push the changes git push
转到您的回购浏览器并检查您的个人资料(右上角)上的用户名和电子邮件
在 git bash 中,根据您的 git web 配置文件更新您的详细信息 git config --global user.email "[email protected]" git config --global user.name "USERNAME"
您将需要撤消提交,然后在步骤 2 中更改用户详细信息后重做
推送更改 git push
回答by Asanka Siriwardena
I had the same issue while working with different projects in my office machine. Git is configured global with my office email '[email protected]'. The other is an open source project of GitLab repository, authenticated by my gmail account.
我在办公机器上处理不同项目时遇到了同样的问题。Git 使用我的办公室电子邮件“[email protected]”进行全局配置。另一个是GitLab仓库的开源项目,通过我的gmail账号认证。
Push for the GitLab repository did not work, showing the same error as above. The reason was, the Author of the commit message was originated from my office email.
推送 GitLab 存储库不起作用,显示与上述相同的错误。原因是,提交消息的作者来自我的办公室电子邮件。
Keeping a different committer name and email per Repository, worked for me. I have modified the user.emailfor the GitLab repository. This is simply omitting the --global flag.
为每个存储库保留不同的提交者姓名和电子邮件,这对我有用。我已经修改了 GitLab 存储库的user.email。这只是省略了 --global 标志。
Now all of your commits will be originated from the new Author you set for the repository preventing the above error.
现在您的所有提交都将来自您为存储库设置的新作者,以防止上述错误。