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
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With