27

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.

Martin Bøgelund
  • 1,681
  • 1
  • 17
  • 26
Oleg
  • 481
  • 1
  • 4
  • 7

8 Answers8

21

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
congusbongus
  • 13,359
  • 7
  • 71
  • 99
Oleg
  • 481
  • 1
  • 4
  • 7
  • 4
    But this only a solution, if you really want to have this disabled. Checking the commiter is a good security feature of Bitbucket. In this case set your global settings correctly. This is the better way to do it. – Christian Müller Jun 27 '20 at 08:51
17

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>
Manish R
  • 2,312
  • 17
  • 13
5

If the issue keep persist even after you set user.email and user.name? You may need change your commit author log to match with this user. Just check the git log before run below cmd.

git commit --amend --reset-author --no-edit
  • 2
    This was the only thing that worked for me, even after updating the Git user and changing the log via `git commit --amend --author="Author Name " --no-edit`. The author was "correct" in the logs but I still could not push until I ran this step with the `--reset-author` flag. Thank you! – bigsee Oct 12 '22 at 07:37
2
  1. Go to your repo browser and check what your username and email is on your profile ( the top right corner)

  2. In git bash update your detail as per your git web profile git config --global user.email "your@email.com" git config --global user.name "USERNAME"

  3. You will need to undo the commit and then redo it after you changes you user detail in step 2

  4. Push the changes git push

Neupane
  • 46
  • 1
1

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

enter image description here

eeijlar
  • 1,232
  • 3
  • 20
  • 53
1

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. enter image description here

Now all of your commits will be originated from the new Author you set for the repository preventing the above error.

Asanka Siriwardena
  • 871
  • 13
  • 18
0

You have to undo the commit that has the incorrect email address, then update the git config as mentioned below. If you committed multiple times you may need to cherry-pick and then commit but only after running through these steps:

# remove "--global" if you only want to update it for the local repo
git config --global user.email "Your Email"
git config --global user.name "Your Name"

Make the new commit and then you should be able to push.

Roger Perez
  • 2,807
  • 29
  • 31
0

Sometimes setting user.email with git command may not set the updated email.

In my case(Windows), I see a .gitconfig file under C:/Users/Mine/.gitconfig.

I edited this file with my desired email and the username.

[user]
name = YourUsername
email = YourEmailId

Done push successfully.

Gv Ravi
  • 333
  • 2
  • 5