更改以前提交的git电子邮件 [英] Change git email for previous commits

查看:109
本文介绍了更改以前提交的git电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我读了很多关于如何更改之前提交的电子邮件地址,但由于某些原因,我的更新没有更新。



我用我的本地电子邮件(nameofMyComputer@kevin.local)向我的私人回购提交了40份提交,因为这封电子邮件没有关联be)with github。

然后我记得我之前需要设置git.config,所以我做了:

  git config user.emailnewemail@example.com





有没有一种方法可以将我以前的所有提交都还原为这封新邮件?



我在SO Change Git中的多个提交的作者和提交者姓名和电子邮件,并使用它

  git filter-branch  - f --env-filter
GIT_AUTHOR_EMAIL='kevin.cohen26@gmail.com';
GIT_COMMITTER_EMAIL='kevin.cohen26@gmail.com';

HEAD

但它不起作用...我仍然可以看到电子邮件我以前用.patch扩展名作为.local电子邮件地址提交

解决方案

您确实可以一次完成许多提交这:

  git rebase -i HEAD〜40 -xgit commit --amend --author'作者姓名< author .name @ mail.com>'--no-edit

a href =https://stackoverflow.com/a/31669789/2082964>这个答案。


So I read a lot about how to change previous commit's email address but for some reason mine is not updating.

I did like 40 commits to my private repo with my local email (nameofMyComputer@kevin.local) which is bad since this email is not associated(and it can't be) with github.

I then remembered that I needed to set the git.config before and so I did:

 git config user.email "newemail@example.com"

and did a test commit and it worked perfectly.

Is there a way I can revert all my previous commits to this new email?

I read this question on SO Change the author and committer name and e-mail of multiple commits in Git and used this

 git filter-branch -f --env-filter "                         
                    GIT_AUTHOR_EMAIL='kevin.cohen26@gmail.com'; 
                    GIT_COMMITTER_EMAIL='kevin.cohen26@gmail.com';
                    " 
                HEAD

But it DID NOT work... I can still see the email of my previous commits with the .patch extension as the .local email address

解决方案

You can indeed do his for many commits at once like this:

git rebase -i HEAD~40 -x "git commit --amend --author 'Author Name <author.name@mail.com>' --no-edit"

I worked this out better in this answer.

这篇关于更改以前提交的git电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆