A few days ago git push
, the following problem occurred when using uploading: After
Baidu search, there are two solutions in total: 1. Change the ssh method to https method, that is, change the method when connecting to the remote warehouse. The configuration of this method is in ~/.git/config
changes in the file. 2. Change the port of ssh, that is, ~/.ssh/config
change it in the file.
Of these two methods, only the second one can succeed on my computer, and the first one still causes errors. Here I simply record:
The first method: change the ssh method to the https method.
- Found
~/.git/config
, you can use the command:git config --local -e
, the following content appears:
[core]
repositoryformatversion = 0
filemode = false
bare = false
logallrefupdates = true
symlinks = false
ignorecase = true
[remote "origin"]
url = [email protected]:Norah2/norah2.github.io.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
[user]
name = nora
email = [email protected]
url = [email protected]:Norah2/norah2.github.io.git
Changing theurl = https://github.com/Norah2/norah2.github.io.git
, is actually changing the originalgit@
tohttps://
, and then:
changing the colon to a slash/
. If you really don't want to change it, you can log in to github, enter the remote warehouse, click on the code and select https, and directly copy the above link.
After the changes were made, save and exit, the problem still occurred when I tried to upload again, so I tried the second method. (The failure of the first method may be because the configuration was not refreshed, and the second method was used later, so I did not continue to test)
The second: change the port of ssh.
- Create a new
~/.git/config
file:vim ~/.git/config
. - Add content inside:
Host github.com
User [email protected]
Hostname ssh.github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa
Port 443
Fill in your email after User on the second line, save and exit after filling.
- You need to re-use the command
git config user.name xxx
andgit config user.email xxx
set it, in order to refresh the configuration.
If you don't have this step, git push
you will still have problems:
- You can use the command
ssh -T [email protected]
to check whether ssh is normal:
after the above operations are completed,git push
it will return to normal after uploading again: