1. 程式人生 > 其它 >github ssh方式push不了,要輸入賬號密碼

github ssh方式push不了,要輸入賬號密碼

技術標籤:git

先github上新建1個專案

本地新建1個專案

push

git init
git add .
git commit -m "first commit"
git remote add origin https://github.com/$account/helloworld.git
git push -u origin master

上面會導致ssh方式push不了,會出現下面問題
在這裡插入圖片描述
在這裡插入圖片描述

解決

git remote -v
git remote rm origin
git remote -v

# 注意這個
git remote add origin git@github
.com:$account/helloworld.git git push -u origin master

push後

git push -u origin master
Enter passphrase for key ‘/c/Users/account/.ssh/id_rsa’:
Counting objects: 39, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (28/28), done.
Writing objects: 100% (39/39), 20.71 KiB | 589.00 KiB/s, done.

Total 39 (delta 2), reused 0 (delta 0)
remote: Resolving deltas: 100% (2/2), done.

總結

也就是要用ssh方式,不要用https方式

新增遠端分支

git remote add origin git@github.com:$account/helloworld.git