You have to set your username and email to be the same in both the machines:
git config --global user.name <name>
git config --global user.email <email>
If you want to change existing commits, be warned that you will be rewriting history.
You can refer to this answer: How do I rewrite committer names in a git repository?