Git推送失败,并出现错误:“ GitLab:作者不是团队成员”

min*_*nil 4 git gitlab

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

remote: GitLab: Author '`SamLogan@logath-T460.mycompany.com`' is not a member of team
Run Code Online (Sandbox Code Playgroud)

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

#git config user.name
Sam Logan 

#git config user.email
SamLogan@mycompany.com
Run Code Online (Sandbox Code Playgroud)

我的主机名是 logath-T460.

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

Gin*_*pin 9

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

默认情况下,如果您没有设置user.name并且user.email 提交之前,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
Run Code Online (Sandbox Code Playgroud)

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

我认为发生的事情,就是你已经提交之前设置正确user.nameuser.email设置。因此,您要推送的那些提交已经将“ SamLogan@logath-T460.mycompany.com”保存为提交作者。

然后,您需要做的就是更新那些提交的作者。首先,请确保正确设置user.nameuser.emailconfig--global--local回购),也就是您的Git身份。

git config --global user.name "yourname"
git config --global user.email "yourname@youremail.com"
Run Code Online (Sandbox Code Playgroud)

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

修改最近提交的作者,请执行以下操作:

git commit --amend --reset-author --no-edit
Run Code Online (Sandbox Code Playgroud)

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

git rebase -i HEAD~N -x "git commit --amend --reset-author --no-edit"
Run Code Online (Sandbox Code Playgroud)

N您需要更新的先前提交次数在哪里。该rebase -i会显示一个命令行编辑向您展示的变化,并且--reset-author将使用当前user.*设置。只需保存并退出即可应用更改。

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


use*_*737 6

我在将项目迁移到新的 Gitlab 站点时遇到了这个问题。对我有用的解决方案在我的新项目中禁用选项“检查作者是否是 GitLab 用户”。

来自Gitlab 文档

GitLab 已经提供了受保护的分支,但在某些情况下,您需要一些特定规则,例如防止 Git 标签删除或强制提交消息的特殊格式。

推送规则本质上是预接收Git 钩子

推送规则“检查作者是否是 GitLab 用户”:

将作者(电子邮件)提交限制为现有 GitLab 用户。

如果这是您的初始提交(如我的情况),您可能只想停用 GitLab 用户检查一次并重新激活它以供将来提交。

该选项可从 Gitlab Starter 7.10 中获得,并且可以在 Web 界面中编辑 settings/repository

在此处输入图片说明

另请参阅:如何绕过:远程:GitLab:作者不是团队成员?

  • 荣誉您的回答解决了我一段时间的问题。取消选中“检查作者是否是 Gitlab 用户”实际上为我解决了这个问题。当在 Gitlab 中使用项目访问令牌来运行语义发布机器人时,这就是我需要做的。:) (2认同)