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.name
和 user.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.name
和user.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/