GitLab: You cannot push commits for . You can only push commits that were committed with one of your own verified emails

0

1

I am having this weird issue where I cloned a repository with my credentials (my_correct@email.adress). But I can not push the changes because I always receive this message:

GitLab: You cannot push commits for 'my_wrong@email.adress' . You can only push commits that were committed with one of your own verified emails.

The issue is that when I check the global and the repository users I find it is my_correct@email.adress:

Global (below confirms my correct address):

git git config  --global user.email
git config  --global user.name

Repository (below confirms my correct address):

git git config  user.email
git config   user.name

What should I do and what is the reason behind this mysterious mystery?

Billal Begueradj

Posted 2019-03-31T15:03:23.233

Reputation: 53

Answers

3

You need to ask an administrator for the repo you cloned your project from to remove the committer restrictions from the push rules on your repo. See [Enabling push rules][1][https://docs.gitlab.com/ee/push_rules/push_rules.html#enabling-push-rules].

walkjivefly

Posted 2019-03-31T15:03:23.233

Reputation: 31

3

I was able to fix the same issue using this git command:

git commit --amend --reset-author --no-edit

I initially tried to commit with the wrong email but even after setting user.name and user.email in git config --global to the correct one, I kept getting the same "You cannot push commits for..." error above.

The solution was resetting the author in git - then the push was accepted to Gitlab.

For reference: https://github.com/git-tips/tips#revert-undo-a-commit-by-creating-a-new-commit

Sarah Ruth Finkel

Posted 2019-03-31T15:03:23.233

Reputation: 31

1

git commit --amend --reset-author --no-edit only changes author in the last commit, if you have multiple commits, you still won't able to push.

Check it with git log, and revert every commit with the improper author and commit again.

Balint

Posted 2019-03-31T15:03:23.233

Reputation: 11