Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git push failed with error: “GitLab: Author not member of team”

Tags:

git

gitlab

git push failed with the following message:

remote: GitLab: Author '`[email protected]`' is not a member of team

My #git config user.name and #git config user.email are set as:

#git config user.name
Sam Logan 

#git config user.email
[email protected]

My hostname is logath-T460.

I am not sure why git push uses my localhostname with the Author. Any clue how to resolve this issue?

like image 646
minil Avatar asked May 16 '19 23:05

minil


2 Answers

It's not git push that's using your username + hostname, it's git commit.

By default, if you did not set user.name and user.email BEFORE making a commit, git will get it from your computer name and hostname. It would also have shown you a warning like this:

Committer: user1234 <[email protected]>
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly:

    git config --global user.name "Your Name"
    git config --global user.email [email protected]

After doing this, you may fix the identity used for this commit with:

    git commit --amend --reset-author

 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 file1.txt

When you do git push, it would just use whatever was set as the commit author and push it to the remote repo.

What I think happened, is that you already committed BEFORE you set the correct user.name and user.email settings. So those commits you're trying to push already has that invalid user details "[email protected]" saved as the commit author.

What you need to do then is to update the author of the previous commits.

First, make sure to properly set the user.name and user.email config (--global or --local to the repo), otherwise known as your Git identity.

git config --global user.name "yourname"
git config --global user.email "[email protected]"

Set it now to the correct identity that matches the user account of your Gitlab repo.

Then use --reset-author on those commits.

  • To modify the author of only the most recent commit:
    git commit --amend --reset-author --no-edit
    
  • To modify the author of multiple past commits:
    (reference: How to amend several commits in Git to change author)
    git rebase -i HEAD~N -x "git commit --amend --reset-author --no-edit"
    
    where N is the number of previous commits you need to update. The rebase -i will show a command line editor to show you the changes, and --reset-author will use your current user.* settings. Just save and quit to apply to changes.

After that, git push should now work.

like image 155
Gino Mempin Avatar answered Nov 13 '22 21:11

Gino Mempin


I had this issue while migrating a project to a new Gitlab site. The solution that worked for me was to disable the option "Check whether author is a GitLab user" in my new project.

From Gitlab docs:

GitLab already offers protected branches, but there are cases when you need some specific rules like preventing Git tag removal or enforcing a special format for commit messages.

Push rules are essentially pre-receive Git hooks

push rule "Check whether author is a GitLab user":

Restrict commits by author (email) to existing GitLab users.

If this is your initial commit (as in my case) you might want to deactivate the GitLab user check just once and re-activate it for future commits.

The option is available from Gitlab Starter 7.10 and can be edited in the Web interface in settings/repository

enter image description here

See also: How to bypass: remote: GitLab: Author is not a member of team?

like image 20
user2314737 Avatar answered Nov 13 '22 23:11

user2314737