Error in git: You can only push your own commits i

2020-08-10 08:20发布

问题:

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.

回答1:

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


回答2:

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>


回答3:

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



回答4:

  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



回答5:

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.