Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change git email for previous commits

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 ([email protected]) 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 "[email protected]" 

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='[email protected]';                      GIT_COMMITTER_EMAIL='[email protected]';                     "                  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

like image 657
Kevin Cohen Avatar asked Jan 18 '16 09:01

Kevin Cohen


People also ask

How do you change the message of a previous commit?

On the command line, navigate to the repository that contains the commit you want to amend. Type git commit --amend and press Enter. In your text editor, edit the commit message, and save the commit.

How do I change the author and committer email in git?

Using Rebase This will change both the committer and the author to your user.name / user. email configuration. If you did not want to change that config, you can use --author "New Author Name <[email protected]>" instead of --reset-author . Note that doing so will not update the committer -- just the author.


1 Answers

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

git rebase -i HEAD~40 -x "git commit --amend --author 'Author Name <[email protected]>' --no-edit" 

I worked this out better in this answer.

like image 118
Chris Maes Avatar answered Sep 28 '22 02:09

Chris Maes