I have a branch, and almost all commits had a wrong email "mywrong@email.com"
and I wanted to change that e-mail to my current email "mynew@email.com"
.
While searching, I found this:
git filter-branch --commit-filter 'if [ "$GIT_COMMITTER_EMAIL" = "mywrong@email.com" ];
then
export GIT_AUTHOR_NAME="Sandrina Pereira";
export GIT_AUTHOR_EMAIL=mynew@email.com;
export GIT_COMMITTER_NAME="Sandrina Pereira";
export GIT_COMMITTER_EMAIL=mynew@email.com;
fi; git commit-tree "$@"'
See here the difference between COMMITTER and AUTHOR. It is important to really change the commit auth, otherwise wit will show that mynew
did a commit under oldnew
original commit. And here I want to change both author and commiter.
Then I did git commit -am "change author"
, git pull
and git push
.
The problem is that now all my commits are duplicated as you can see here
I searched how to delete those commits and I found this:
git filter-branch --commit-filter '
if [ "$GIT_AUTHOR_EMAIL" = "mywrong@email.com" ];
then skip_commit "$@";
else git commit-tree "$@";
fi' HEAD
But I didn't try it yet... What should i do?
And on the next time I want to replace the e-mail commits what is the right command to avoid this mess?