Have you ever realized you committed code under the wrong author name?
Maybe you forgot to switch users after working on a shared project, or perhaps someone else accidentally committed using your details.
This guide shows you exactly how to change the author name for any commit, step by step, so you can keep your Git history clean and accurate.
Steps to follow:
1. Run the command 'git log' to view the commit history.
2. To change the commit author using interactive rebase, run the command 'git rebase -i <commit-id>'.
3. Replace the word 'pick' with 'edit' for the commit you want to modify.
4. To save and exit the editor, press 'Esc', type ':wq', and then press Enter.
5. When the rebase stops, run the command 'git commit --amend --author="new author name <newauthor@gmail.com>"'.
6. To save and close the editor, press 'Esc' and type ':qa', then hit Enter.
7. After modifying the author, continue the rebase process with 'git rebase --continue'.
8. After the rebase is complete, use 'git log' to verify that the author name has been changed.
That's it!
You've successfully changed the author name for a commit.
Changing the author name for a commit is much easier than it seems once you know how to do it.
By following this step-by-step guide, you can fix any mistakes in your Git history and ensure the right contributors get credit for their work.
Now that you know how to do it, keeping your projects organized and properly attributed is just a few commands away!
Still have questions?
Send an email to archana@leadwalnut.com, OR
Book a FREE consultation with an expert developer here.