2

Scenario

Right so I've had this problem for a while, and to put things across quickly I'm trying to pull from a private repo but its saying that it doesn't exist. That leads me to believing that the stored git user details are that of a different account.

I have two git accounts, one for work related stuff and one for personal stuff.

I'm trying to pull from a private repo on the work account. But I'm not sure if my local git account is the work one or not because I've changed the git config user.email/user etc globally to use the work email details but its not working. (originally it was the personal account)

The error message shows this

$ git pull
remote: Repository not found.
fatal: repository 'https://github.com/username/repo.git/' not found

I believe that if I add the personal account as a collaborator it will work. So I'm not sure why changing the git credentials doesn't allow me to push to that repo.

If any more information is needed let me know and I'll provide it / edit the question

My Question

How do I change which account is being used to perform my git actions. I want to be able to push / pull as the work account.

For reference again I've changed the git config and git config --global information to that of the work account.

Ishan Thilina Somasiri
  • 1,179
  • 1
  • 12
  • 24
Kenziiee
  • 33
  • 1
  • 5

3 Answers3

1

For me cloning/adding remote with the following format did the trick.

https://username:password_without_@_char_in_between@github.com/org_name/repo_name.git

Kishor Pawar
  • 3,386
  • 3
  • 28
  • 61
0

I imagine this is an issue with the remote user repository URL. See: Change Git Username in Terminal

Specifically: 'git remote set-url'

Moving forward, it might be valuable to setup a more stable environment (to maintain both accounts on the machine). See: http://mherman.org/blog/2013/09/16/managing-multiple-github-accounts/

  • The remote URL is correct, and i know this because once i add the current user to the collaborators list everything starts working without me changing details further, but ill check the second link you sent me then get back to you, thanks for this – Kenziiee Jan 07 '18 at 00:37
  • No problem! Hope you find the solution to the problem. Tricky to diagnose without more information. To make sure it isn't anything trivial, you might also want to just check against each of these: https://help.github.com/articles/error-repository-not-found/ – Peter Barrett Bryan Jan 07 '18 at 05:10
0

Since you are trying to access the repository with the https://github.com/usernameA/repo.git/ URL format, it is required for that user to have collaborator access. So first check whether usernameA has access to that particular repo.

And I assume that you have two SSH keys generated for the personal and work accounts. If you want to access GIT using work SSH key only, You could ask GIT to use the work SSH key always.

git config core.sshCommand "ssh -i ~/.ssh/WORK_SSH_KEY -F /dev/null"

First try with this whether it works. Then if it does, that means you have a problem with SSH keys. Then you have two approaches to solve this.

Ishan Thilina Somasiri
  • 1,179
  • 1
  • 12
  • 24
  • I think my point is being missed here, im asking why do i need to add as a colaborator. Im trying to make git be used by the work account NOT the personal account. How do i "login" to the work account so i dont need to give another account access? – Kenziiee Jan 07 '18 at 12:00
  • Does the URL you try to use to get access to the repo, `https://github.com/usernameA/repo.git/`, contains the work account name? – Ishan Thilina Somasiri Jan 07 '18 at 13:07