Issue
I have two GItHub accounts on one computer - one for work and one for my own projects. Despite reading a virtual pile of guides setting up a working system, I have so far failed - the work account pushes-pulls correctly but my own account either fails (ERROR: repository not found) or asks for credentials (which fails because the method is disabled).
So far I have the following:
Working ssh keys for both accounts
(tested with ssh -T [email protected]
and [email protected]
)
A config file in .ssh directory:
#Worker account
Host github.com-Worker
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa_worker
#HobbyHorse account
Host github.com-HobbyHorse
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa_hobby
Pushing and pulling on the work account succeeds (and I am able to work), but fails on my own account. Somehow I am unable to tell git to use the HobbyHorse key for logging in.
git config --local --get user.name
correctly gives 'HobbyHorse
git remote add origin [email protected]:HobbyHorse/HobbyProject.git git push --set-upstream origin master
gives the error: `ERROR: Repository not found. fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists. ` I am sure I've checked for typos and such. What is the problem?
Solution
You set up specific hostnames in ~/.ssh/config
but you didn't use them. It's about the same as if you put a friend's name and new phone number in your address book, and then kept texting or calling the old number.
For the existing repo you mentioned, git remote set-url origin github.com-HobbyHorse:HobbyHorse/HobbyProject.git
should fix it.
For new repos, git clone github.com-HobbyHorse:owner/repo
will clone with your "HobbyHorse credentials", and git clone github.com-Worker:owner/repo
will clone with your "worker" credentials.
Answered By - Jim Redmond Answer Checked By - Pedro (WPSolving Volunteer)