这不是git push使用的用户名,而是git commit.

默认情况下,如果您没有设置user.name并且user.email 提交之前没有设置,git 将从您的计算机名和主机名中获取它。它还会向您显示如下警告:

Committer: user1234 <user1234@mac.local>Your name and email address were configured automatically basedon 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 you@example.comAfter 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

当您这样做时git push,它只会使用设置为提交作者的任何内容并将其推送到远程存储库。

我认为发生的事情是您设置正确user.nameuser.email设置之前已经承诺因此,您尝试推送的那些提交已经将无效的用户详细信息“SamLogan@logath-T460.mycompany.com”保存为提交作者。

然后你需要做的是更新之前提交的作者。

首先,确保正确设置user.nameuser.email配置--global--local到 repo),也称为您的 Git 身份。

全局
git config --global user.name "yourname"
git config --global user.email "yourname@youremail.com"
执行命令前cd到项目根目录;仅针对当前项目生效
git config user.name "yourname"
git config user.email "yourname@youremail.com"

现在将其设置为与您的 Gitlab 存储库的用户帐户匹配正确身份

然后--reset-author在这些提交上使用

  • 修改最近提交的作者:

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

修改多个过去提交的作者:(
参考:如何在 Git 中修改多个提交以更改作者

git rebase -i HEAD~N -x "git commit --amend --reset-author --no-edit"
  • 那里N是您需要更新的先前提交的数量。rebase -i会显示一个命令行编辑向您展示的变化,并且--reset-author将使用当前user.*设置。只需保存并退出即可应用更改。

之后,git push现在应该可以工作了。


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