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

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 “SamL[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.

Leave a Comment