10

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.

Amjad
  • 3,110
  • 2
  • 20
  • 19

4 Answers4

37

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.

foobar
  • 133
  • 1
  • 7
6

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.

hardillb
  • 54,545
  • 11
  • 67
  • 105
0

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.

Prabhakar
  • 237
  • 1
  • 3
  • 10
0

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.

  1. Check your current Git configuration:
git config --global --list
  1. 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
  1. (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
Hyder B.
  • 10,900
  • 5
  • 51
  • 60