I made a commit with the wrong email "[email protected]" and when I tried to push the commit, It failed for the following reason
remote: GitLab: Committer's email '[email protected]' does not follow the pattern '@company.fr$'
To gitlab.com:xxxxxx.git ! [remote rejected] xxxx -> xxxx (pre-receive hook declined)
error: failed to push some refs to 'xxxxx'
I forced a changed in the commit's email with the command:
git commit --amend --reset-author
I forced the change in the email address to the right address "[email protected]" and the logs show that the change has been effective
But when I try to push (with --force) the commit, I still have to same error above.
If you have any idea why it doesn't work and how I can force it, I would gladly welcome it
Thank you
I have also seen this problem with Bitbucket, and I also don't know why it happens (it should not based on my understanding). What I have found works is correcting the user email profile locally in Git, and then recommitting. Try the following:
# from your feature branch
git branch backup # create backup branch
git reset --hard HEAD~1 # remove the problem commit
git cherry-pick <SHA-1 of HEAD of backup> # cherry-pick back the commit
git push origin feature
When you cherry-pick back your commit, you are essentially creating a brand new commit, with the correct email address the first time around. I have seen this approach work with Bitbucket, and it is worth trying with Gitlab.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With