I was writing a simple script in the school computer, and committing the changes to Git (in a repo that was in my pendrive, cloned from my computer at home). After several c
Change commit author name & email
by Amend
, then replacing old-commit with new-one
:
$ git checkout # checkout to the commit need to modify
$ git commit --amend --author "name " # change the author name and email
$ git replace # replace the old commit by new one
$ git filter-branch -- --all # rewrite all futures commits based on the replacement
$ git replace -d # remove the replacement for cleanliness
$ git push -f origin HEAD # force push
Another way Rebasing
:
$ git rebase -i # back to last good commit
# Editor would open, replace 'pick' with 'edit' before the commit want to change author
$ git commit --amend --author="author name " # change the author name & email
# Save changes and exit the editor
$ git rebase --continue # finish the rebase