Git 推送失败,错误为 : “GitLab: Author not member of team”

标签 git gitlab

git push 失败并显示以下消息:

remote: GitLab: Author '`SamLogan@logath-T460.mycompany.com`' is not a member of team

我的#git config user.name 和#git config user.email 设置为:

#git config user.name
Sam Logan 

#git config user.email
SamLogan@mycompany.com

我的主机名是 logath-T460。

我不确定为什么 git push 将我的本地主机名与作者一起使用。任何线索如何解决这个问题?

最佳答案

不是 git push 使用您的用户名 + 主机名,而是 git commit

默认情况下,如果您没有设置 user.nameuser.email BEFORE 进行提交,git 将从您的计算机名和主机名。它还会向您显示如下警告:

Committer: user1234 <user1234@mac.local>
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 you@example.com

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

当您执行 git push 时,它只会使用设置为提交作者的内容并将其推送到远程仓库。

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

然后您需要做的是更新以前提交的作者。

首先,确保正确set the user.name and user.email config (--global--local 到 repo),也称为你的 Git 身份。

git config --global user.name "yourname"
git config --global user.email "yourname@youremail.com"

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

然后使用--reset-author在这些 promise 上。

  • 修改最近提交的作者:
    git commit --amend --reset-author --no-edit
    
  • 修改过去多次提交的作者:
    (引用:How to amend several commits in Git to change author)
    git rebase -i HEAD~N -x "git commit --amend --reset-author --no-edit"
    
    其中 N 是您需要更新的先前提交的数量。 rebase -i 将显示一个命令行编辑器来向您展示更改,--reset-author 将使用您当前的 user.*设置。只需保存并退出即可应用更改。

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

关于Git 推送失败,错误为 : “GitLab: Author not member of team” ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56177751/

相关文章:

git - 查看个别家长的git diff

git - E : Unable to locate package git - Ubuntu on EC2

nginx - 通过综合包安装 gitlab 与手动安装有什么含义和区别?

amazon-web-services - 如何在 gitlab CI/CD 中使用 zappa 将应用程序部署到 AWS Lambda?

gitlab - 如何在 Gitlab 中添加组审阅者?

docker - 如何使用 docker 为 gitlab 托管的项目运行 gitlab-runner?

git - 为什么我们在 git 中需要 SSH key ?

git - 从远程仓库克隆写入 git 目标文件

git - 当我执行 git Branch -a 时,分支下的分支会是什么样子?

docker - 你如何查看在 gitlab-runner exec 期间创建的日志?