Having several users on a GIT hosting service is quite normal: a user for your professional projects, a user for a company that you work with/for, a user for your pet projects and so on. Different users need different SSH keys registered with the same GIT service provider, so your PC may show messages like the following when you try to clone a project:
Permission denied, please try again.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
You know that you have the right access, because you can check it in their web client after logging in with the right user. But your git CLI is using a different user. How can you solve this without changing your global GIT settings?
We are going to specify the right user, email and, especially, the right SSH key to be used for this project:
I assume that you work with Linux/Mac
Project folder
$ mkdir <Project Name>
$ cd <Project Name>Creation of the GIT repository
$ git initRight user association
$ git config user.name <Your name>
$ git config user.email <Your email>
$ git config core.sshCommand "ssh -i <Path to your SSH key> -F /dev/null"Adding the remote
$ git remote add origin <Project Remote URL>Pull the master branch
$ git pull origin masterDefault master branch
$ git branch --set-upstream-to=origin/masterFetch All
$ git fetch --allWith this solution, you directly associate this GIT repository with the right GIT user without affecting any other GIT configuration on your PC.