I am concerned about my privacy and don't want my real name appearing on my github commits. I just discovered that github is saving my user.name as the contributor as well as my github username. I have now changed my local git user.name so future commits will be fine. But now I'm wondering how can I go back and change the user.name that did commits previously in a repo on github?
Asked
Active
Viewed 3,306 times
1 Answers
0
Besides filter-branch as suggested in a comment, interactive rebase is another option.
Using Interactive Rebase
git rebase -i -p <some HEAD before all of your bad commits>
Then mark all of your bad commits as "edit" in the rebase file. Then, when git asks you to amend each commit, do
git commit --amend --author "New Author Name <email@address.com>"
Save and close the editor that opens, and then do
git rebase --continue
to continue the rebase.
Add --no-edit
to skip opening the editor so that the command will be:
git commit --amend --author "New Author Name <email@address.com>" --no-edit && \
git rebase --continue
To change both author and committer:
git -c user.name="New Author Name" -c user.email=email@address.com commit --amend --reset-author

Ashutosh Jindal
- 18,501
- 4
- 62
- 91