0

Let say I have 2 user accounts. Mostly I use user1 even I authorized user1 into my VSCode so I don't have to put my credentials when I am pulling and pushing my commit.

When I created user2, I changed my credentials on my VSCode. And I got invited into organization and its repository using user2. But when I am pushing my commit to GitHub, it shows that the commit was made by user1 (not user2) even when I tried git config --list on my local folder it shows user1.

What should I do to change it so my commit will appear from user2 ?

ryanadhi
  • 67
  • 1
  • 8
  • Does this answer your question? [How to change the author and committer name and e-mail of multiple commits in Git?](https://stackoverflow.com/questions/750172/how-to-change-the-author-and-committer-name-and-e-mail-of-multiple-commits-in-gi) – Enrico Campidoglio Sep 04 '20 at 09:07

3 Answers3

0

You have to change the user in the git config, so your commits are done as this user. As far as I am aware, Github matches the (Github) users via the email adress that is given as the user of the commit.

kutschkem
  • 7,826
  • 3
  • 21
  • 56
0

While configuring Git Credentials, it always configures it only for that current folder.

To configure it globally, use the --global parameter as follows:

git config --global user.email name@example.com
git config --global user.name First Last

you can also manually edit the git config opening the file: ~/.gitconfig

Kai
  • 323
  • 2
  • 10
0

On the project you are working on, you have to configure git to use user2. This can be done in the following two ways.

Either edit your local .git/config file, where you have to edit these lines

[user]
    email = user2@mail.com
    name = Name

or through the command line git config --local.

Keep in mind that GitHub uses only one primary account to display when committing. You can change this by adding another email to your GitHub account and make that your primary email for any work you do.

mnestorov
  • 4,116
  • 2
  • 14
  • 24