old_email = b"old@mail.com" new_email = b"new@mail.com" new_name = "newname" if commit.author_email == old_email: commit.author_name = new_name.encode("utf-8") commit.author_email = new_email if commit.committer_email == old_email: commit.committer_name = new_name.encode("utf-8") commit.committer_email = new_email