0


Git修改commit的作者信息

最近在使用gitlab时,遇到报错

GitLab: You cannot push commits for '[email protected]' . You can only push 
commits that were committed with one of your own verified emails.

原因是git config中设置的作者邮箱与gitlab中设置的作者邮箱不符,导致了gitlab禁止上传。如果想要push到gitlab中,需要将有问题的commit的作者信息进行修改。修改步骤如下:

  1. 首先通过git log确定想要修改最近的几个commit信息
  2. 使用指令git rebase -i HEAD~2注意将2换成自己想要修改的commit的个数,之后将每个commit前面的pick修改为edit,保存并退出
  3. 使用git commit --amend --author="作者 <邮箱@xxxx.com>" --no-edit指令对commit的作者信息进行修改,需要注意的是,这条指令只能修改第一条commit,而非所有需要修改的commit。
  4. 使用指令git rebase --continue,将刚刚修改的一次commit进行提交
  5. 重复第3、4步,直到将所有commit都修改完成
  6. 使用git push推送到远程仓库
标签: git

本文转载自: https://blog.csdn.net/muguang629/article/details/135513107
版权归原作者 暮光629 所有, 如有侵权,请联系我们删除。

“Git修改commit的作者信息”的评论:

还没有评论