【git】fatal: Could not read from remote repository.
- Prerequisite operation
- Report an error code
- Error correction process
- Reason for the error
- How to deal with it
- Learned
- question
- grateful
)
Prerequisite operation
I haven't used git for a long time, I have a hunch that this will be a ** mistake
I git clone /username/
Report an error code
Cloning into 'offer-Java'...
ssh: connect to host port 22: Connection timed out
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
- 1
- 2
- 3
- 4
- 5
- 6
- 7
Error correction process
-
First read Youdao’s previous notes (I don’t know what I wrote, it’s useless)
git pull
Question: could not read from remote repository…
Reason: git remote -v comes outssh …
I git set-urloriginhttps://… Change the address
git remote -v or ssh
It is because the commit method is ssh, and my remote repository does not have a public key added
Solution: 1. Change the submission method to https
This requires a password to be entered every time you submit it
2. Create and add the public key to the remote repository
git remote -v git view remote repository address command -
Use command to change ssh to https failed
-
Search for "Ssh to change to http failed", no results
-
Search for "git clone error", time limit is within one year, successful
-
ssh-add ~/.ssh/id_rsa error:
Could not open a connection to your authentication agent
- 1
First execute the following command:
ssh-agentbash (I solved it through this method)
Or close the current git bash window and run git bash as administrator again (written by another blogger)
Reason for the error
Root cause: ssh key expires
How to deal with it
- ls ~/.ssh Does ssh key exist in the local machine
Existing display id_rsa id_rsa.pub known_hosts - Delete
Go to /c/Users/ASUS/.ssh and delete id_rsa, id_rsa.pub files - Create a new ssh key and add it to github
ssh-keygen -t rsa -b 2048 -C “username@”
ssh-add ~/.ssh/id_rsa
cat ~/.ssh/id_rsa.pub
Learned
- Does the ssh key exist in this machine
- ls ~/.ssh Displays all files in the ssh directory, if any, the following is displayed
id_rsa id_rsa.pub known_hosts
- 1
- cd ~/.ssh toggle directory
ls displaycurrentFiles in the directory - ls -al ~/.ssh Displays all files and information in the ssh directory
No such file or directory //Then it means there is no SSH key locally
- 1
If an SSH key already exists, the existence of the id_rsa and id_rsa.pub files and its creation date will be displayed.
For example, I show
Total 29
drwxr-xr-x 1 ASUS 197121 0 March 3 2019 ./
drwxr-xr-x 1 ASUS 197121 0 February 5 16:22 ../
-rw-r--r-- 1 ASUS 197121 1675 March 3 2019 id_rsa
-rw-r--r-- 1 ASUS 197121 403 March 3 2019 id_rsa.pub
-rw-r--r-- 1 ASUS 197121 1197 March 8 2019 known_hosts
- 1
- 2
- 3
- 4
- 5
- 6
- mkdir ~/.ssh Create .ssh folder
question
- What is ssh-agent bash for?
Answer: Enter the public key and log in to all devices without password - Why did switching from ssh to https at the beginning fail?
git remote set-url origin https://email/username/
Answer: Don't know - The difference between searching for https and ssh online says that when using ssh when clone, you must be an administrator or own, and you need to enter a password, but after setting it up, clone succeeds.
Answer: ssh-keygen configures SSH without password login
grateful
/sheldonxu/archive/2012/09/17/
/p/2791d5cb762a
/weixin_44394753/article/details/91410463