Git Push Could Not Read From Remote Repository
Earlier you lot can read from a private repository or write to a Git repository, yous must exist authenticated. If you apply the wrong Uniform Resources Locator (URL) to connect to a repository, or have incorrectly fix up your Secure Shell (SSH) authentication, you lot'll encounter the "fatal: Could not read from remote repository" error.
This guide discusses what this mistake means and why you may see information technology. It walks you through two potential solutions so you tin can overcome this problem when using Git.
fatal: Could not read from remote repository
SSH is a protocol for authenticating with remote devices. SSH is commonly used to authenticate with Git because you don't need to blazon in your password every time you cosign.
Every platform has its own way of authenticating users over SSH. Using GitHub, for instance, you must provide your SSH key on their dashboard. Then, you can employ the SSH URL associated with your repository to authenticate with GitHub.
By default, the private SSH key for your device volition be in a file chosen ~/.ssh/id_rsa. This file is in the hidden .ssh directory in your root binder. This key will just exist if you lot have generated it. Otherwise, you lot'll need to use the ssh-keygen command to generate a new cardinal.
If yous accept non correctly set upwardly SSH authentication, Git volition be unable to verify your identity.
The two mutual causes to the "fatal: Could non read from remote repository" error are:
- Not adding your SSH cardinal to the SSH agent
- Using a HTTP URL to connect to a repository
Permit's hash out each of these causes.
81% of participants stated they felt more confident most their tech task prospects after attending a bootcamp. Get matched to a bootcamp today.
The boilerplate bootcamp grad spent less than 6 months in career transition, from starting a bootcamp to finding their first job.
Cause #ane: SSH Agent Effect
The SSH amanuensis stores your SSH key. When you try to authenticate with a Git repository over SSH, Git will check the SSH agent for your primal.
Your SSH key can be removed from the SSH agent for various reasons. This will make it impossible to authenticate with a Git repository.
Permit'south try to clone a Git repository that is individual to our local machine:
git clone git@github.com:career-karma-tutorials/ck-git
When nosotros effort to sign in, the Git command line returns an fault:
fatal: Could not read from remote repository.
This error informs u.s. nosotros accept an authentication result. If you encounter an SSH authentication upshot, your first port of call is to add your cardinal to the SSH keychain:
This will add our id_rsa key to the keychain.
Another common error is to add together the wrong key to your keychain. If you use a cardinal with a unlike name than id_rsa to authenticate with Git, make certain you add that key to your keychain and not the id_rsa key.
Cause #2: Using a HTTP URL
In that location are two means you lot can authenticate with Git: over HTTP and SSH. The Hypertext Transfer Protocol (HTTP) method requires specifying your username and password to a Git server to access a repository.
To authenticate with HTTP, y'all'll use a URL that looks like this:
https://github.com/career-karma-tutorials/ck-git
You lot cannot utilise this URL to connect to a Git server over SSH. This is because SSH and HTTP are dissimilar protocols. If you lot try to sign in to the above URL using SSH, y'all'll be prompted to enter your username and password.
We've got to use an SSH URL to connect to a repository over SSH. You can verify the URLs that yous use to connect to a remote repository using the git remote -v command:
origin https://github.com/career-karma-tutorials/ck-git (fetch) origin https://github.com/career-karma-tutorials/ck-git (button)
We tin can see that our "origin" remote uses HTTP instead of SSH. For an existing repository, we can modify our URL to employ SSH using the git remote set-url control:
git remote ready-url origin git@github.com:career-karma-tutorials/ck-git
This control sets the "origin" URL to be equal to our SSH URL. Now that nosotros've run this control, our existing Git repository will use the SSH URL to connect to the remote version of the repository.
If you are cloning a new repository, you don't need to change the URL with which you are working. Instead, yous just demand to make sure yous use an SSH URL to clone the repo:
git clone git@github.com:career-karma-tutorials/ck-git
Now, we can run commands like git pull, git commit, and git push button on our repository because nosotros take the right admission privileges.
Conclusion
The Git "fatal: Could not read from remote repository" error occurs when there is an effect authenticating with a Git repository. This is mutual if yous have incorrectly fix SSH authentication.
To solve this error, brand certain your SSH key is in your keychain and you connecting to a repository using the correct URL.
Source: https://careerkarma.com/blog/git-fatal-could-not-read-from-remote-repository/
Belum ada Komentar untuk "Git Push Could Not Read From Remote Repository"
Posting Komentar