User name and email can be modified using following command:
git config --global user.name "My user name"
git config --global user.email "me@example.com"
Already done commit can be modified using this command :
git commit --amend --reset-author
Editing a specific commit for a commit history of a1-a2-a3-a4, where a4 is the HEAD. Lets say you want to edit a3 and a4. Run theses commands:
- git rebase -i a2
- This will open the commit message window/terminal.
- Replace "pick" with "edit" for the commits that you want to change author info of.
- It will pause at a3, and would give you chance to edit your author for a3 commit.
- Now edit the commit: git commit --amend --author="authorname <user@email.com>"
- Execute : git rebase continue --
- It will pause at a4, and would give you chance to edit your author for a4 commit.
- Execute: git commit --amend --author="authorname <user@email.com>"
- Execute: git rebase continue --
- You're done !