How to change Author of a previous Git Commit.
PURPOSE
To change the Author of a previous commit in a Repository.
Many times you end up commiting and pushing changes to a repository from a different account than you originally intended to do. You can ignore that commit, and move on in life Or You can follow these steps below:
Assume for clarity of exposition that 03f482d6 is the commit whose author we are trying to replace, and 42627abe is the commit with the new author.
- Open Terminal.
- Change the current working directory to your local project.
- Checkout the commit we are trying to modify.
- Make the author change.
- Now we have a new commit with hash assumed to be 42627abe.
- Checkout the original branch. For example if the original branch was master.
- Replace the old commit with the new one locally.
- Rewrite all future commits based on the replacement.
- Remove the replacement for cleanliness.
- Push the new history (only use --force if the below fails, and only after sanity checking with git log and/or git diff).
Note: Instead of 7-9 you can just rebase onto new commit:
CREDITS
This article is from a StackOverflow Answer here I am adding it here to quickly reference it when I inevitably forget how to do it.