If I committed to github with a wrong local credentials (username and password), will it be possible to change the committer name on github? This issue can happen if you have two git accounts! By the way I'n not asking how to reconfigure your local git account.
4 Answers
1- configure your new username and email with
change username: git config username.user <username>
change email: git config username.email <email>
2- run this command git commit --amend -C HEAD --reset-author
3- run this command git push --force
This will change the other in the last commit.

- 133
- 1
- 7
-
2for me `git config user.email
` worked – ericdemo07 Nov 26 '21 at 19:34 -
2Using `git config user.name
` and `git config user.email – mmccabe Nov 30 '21 at 15:34` worked for me
You can change the last commit locally with
git commit --amend --author="Author Name <email@address.com>"
Then do a
git push --force
This will force the authored commit over the top of the old one.

- 54,545
- 11
- 67
- 105
-
1Did not work for me. I got `fatal: --author 'username
' is not 'Name – Amjad Dec 27 '16 at 18:14' and matches no existing author` -
try replacing "Author Name
" with just the email address of the user you wish to use – hardillb Dec 27 '16 at 18:16 -
I did I just did not want to share them publicly here that is why I change them. – Amjad Dec 27 '16 at 18:17
-
In my case, I have two GitHub accounts (A and B). I had created a repository using A and in local while configuring git,used email id of B account. So whenever I was pushing the code from my local, git was inferring the account B as author. So even though, I had used credentials of Account A, it was still showing author B for all commits done using local machine.
Fix
Configured email in local for Account A and issue got resolved. Further, all commits were showing correct author as A.

- 237
- 1
- 3
- 10
For commits to be linked to your Github account, your email or username in your local git configuration should match the one you have on Github.
- Check your current Git configuration:
git config --global --list
- Update your email or your username as the same value in your Github account:
git config --global user.email "xyz@gmail.com"
git config --global user.name XYZ
git config --global user.username xyz
- (Optional) If you want to change previous commits to reflect your new email/username. Be careful, though, if the repository have a multi-user commits, this will change all commits to have the same new author.
git filter-branch -f --env-filter "GIT_AUTHOR_NAME='Newname'; GIT_AUTHOR_EMAIL='new@email'; GIT_COMMITTER_NAME='Newname'; GIT_COMMITTER_EMAIL='new@email';" HEAD

- 10,900
- 5
- 51
- 60