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.
remote: You can only push your own commits in this repository
remote: Commit commitName was committed by <myName> <my@users.noreply.github.com>
To ssh://bitbucket.awg.ru/repo
! [remote rejected] branchName -> branchName (pre-receive hook declined)
error: failed to push some refs to 'ssh://git@bitbucket.awg.ru/repo'
Update
Thanks everybody, the problem is solved. The problem was on the Bitbucket side, the admininstrator changed some options. Now everything is OK.
Thanks everybody, problem is solved. Problem was on Bitbucket side, administrator changed some options. Now everything is OK.
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.
To solve the issue:
- You must have Admin access to the repository in Bitbucket server
- Go to the repository in the server
- Then ⚙ Repository settings in the sidebar
- Select Hooks
- Disable Verify Committer hook
- You are done
You will need to set your identify before pushing it to bitbucket
git config --global user.email "Your Email"
git config --global user.name "Your Name"
git push origin <branch-name>
Assuming you have already done git config as per @Manish R answer, then check that Bitbucket hasn't enforced the Verify Committer hook. See Project -> Settings -> Hooks
I had the same issue while working with different projects in my office machine. Git is configured global with my office email 'asankasi@abc.com'. The other is an open source project of GitLab repository, authenticated by my gmail account.
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.
Keeping a different committer name and email per Repository, worked for me. I have modified the user.email for the GitLab repository. This is simply omitting the --global flag.
Now all of your commits will be originated from the new Author you set for the repository preventing the above error.