panthro
panthro

Reputation: 24061

Pushing to Git with two accounts

I followed this tuotrial on how to have two separate git accounts on the same machine.

I'm having trouble pushing changes from my second account, they always come from my first one or it says I do not have access rights.

Here's what I do:

Create a folder for my project on my computer and do

git init

Do a pull:

git pull https://github.com/panthro/test master

Then:

git remote add origin git@github-panthro:pantro/test.git

Then:

git push origin master

This gives the error:

ERROR: Permission to panthro/test.git denied to MyOriginalGitHubName.
fatal: Could not read from remote repository.

Config:

Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa
Host github-panthro
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa_panthro

Upvotes: 2

Views: 121

Answers (1)

FATEMEH MOUSAVI
FATEMEH MOUSAVI

Reputation: 21

You should first do this for your second account:

git remote -v

to see how many remotes do you have.

Then, you can remove the first remote with this code:

git remote rm <remote-name>

And finally use:

git remote add origin <url>

Upvotes: 1

Related Questions