windowsgitgithubgit-bashmultiple-accounts

Gitbash changing github account


I was using github account A on gitbash and I wanted to switch to B.

I deleted the credentials for github from control panel for account A and signed with B

When I run git config --list, user.email and user.name matched with account A

than I did: git config --global user.name "AccountB'sname" git config --global user.email AccountBemail

When I run git config --list , Now user.email and user.name matches with account B. And when I make a commit, It is seem to be with account B. So it's good.

My first question is: Is it all to do when changing github account on gitbash ?

2- why on my first git config --list run, name and email did not match even tho I updated credentials from control panel


Solution

  • Your GitHub credentials and your Git config are two unrelated things.

    When you set user.name and user.email, what you are changing is the metadata that will be used in any commits your create. Creating commits is a local operation on your machine, and does not involved talking to GitHub or any other Git server.

    When you want to connect to GitHub using a different account, you did the right thing: change your credentials for GitHub in the Windows Credentials Manager. That will not affect how commits are created on your machine, only how you will authenticate yourself when connecting to GitHub.