32

I have a github account which is configured in my windows pc. Now I have created a new Github account and want to use the new one.

How will I remove my old account from my windows pc and add the new github account ?

NOTE: I have edited the gitconfig file and added the new user email and username there. But the public key still contains the old user email !!

Ebrahim Khalilullah
  • 556
  • 1
  • 6
  • 10

6 Answers6

62

For windows machine

you can manage windows credential for doing this

go to search button then write

manage windows credential

then you will find a button double click it

then remove your current windows credential

after that when you are using git again git authentication will be asked

then you will enter your new github id

Next you need to edit .gitconfig file

file path will be like

C:\Users\Imu

here imu is my user name it will be different in yours

Now edit .gitconfig file using text editor like nodepad++ or sublime text with ur current id information

hoping it helps

SHAH MD IMRAN HOSSAIN
  • 2,558
  • 2
  • 25
  • 44
17

You can use Credential Manager for adding/deleting/modifying existing Github accounts. Steps:

  1. Go to Start -> Type 'Credential Manager' -> Open Credential Manager
  2. Below window will be displayed

enter image description here

  1. Go to 'Windows Credentials' -> Generic Credentials
  2. You will see an entry for Github

enter image description here

  1. Click on the entry -> You will see below options

enter image description here

  1. You can edit the entry -> Add new username and password -> Click on Save

enter image description here

Hope this helps!

Atul
  • 857
  • 8
  • 14
6

Edit 2:

It seems like you are trying to generate a new SSH key for your new account. If that's the case and you think your public key is specified for your old account, you shouldn't worry acording to this post. The comment at the end of your publc key is JUST a comment. You can generate a new one with a different comment if you want to.

Original content :

If you are using Bash, you can use your favorite text editor and open the .gitconfig file yourself and remove the credentials you don't want. It is located (in Bash) at "~/.gitconfig".

e.g.:

nano ~/.gitconfig

I'm pretty sure there is a command you could do for this, but this is how I would do it.

Edit:

Here is a command line that could do it :

git config {--global|--system|--local} --edit

This command line will do exactly the same as the first command line I mentionned except that this one is working not only on Bash and you don't have to know the location of the file by heart. It will use your default text editor.

{--global|--system|--local}

Means only one of the three options. Use only one depending on the config file you want to edit. Personaly I would not edit the system one, so just look in your local ones (for the repositories you need to) and in the gloabal one.

P.S.: I assume you are using command lines. If you don't, I suggest you to try it.

Jo Ham
  • 149
  • 1
  • 11
  • I have updated the config file already. But when I generate publick key to add in github, it still shows the old public key which contains the email of old github account. !!! – Ebrahim Khalilullah Apr 24 '17 at 05:18
2

run

nano ~/.gitconfig 

delete unnecessary items which are other than your name and email.

save

check for git config

run:

git config -l

or

git config --global -l 
Paul Roub
  • 36,322
  • 27
  • 84
  • 93
Diana
  • 1,091
  • 1
  • 9
  • 11
1

Just changing name and email on .gitconfig didn't work here.

It took effect only after running:

git credential-manager-core configure

fariaseduv
  • 87
  • 5
0

The easier way is just to change the GitHub account used on your local machine by this command:

open your terminal and write these commands

git config --global user.name "your new username"
git config --global user.email "your new email"

Then Git will use these credentials instead of the old one

Ali Zedan
  • 285
  • 3
  • 17