本地 push 到github 每次都需要輸入用戶密碼問題

在github.com上 建立了一個小項目,可是在每次push  的時候,都要輸入用戶名和密碼,很是麻煩,用戶體驗很差,後來發現其實是自己沒有使用正確的方式。

有兩種方式push ,如何查看是哪種方式了?

git remote -v 指令 返回類似如下:

huruzun@huruzun-All-Series:~/learngit$ git remote -v
origin	https://github.com/huruzun/learngit.git (fetch)
origin	https://github.com/huruzun/learngit.git (push)

這裏顯示是https方式進行push 操作,現在需要更改成通過ssh 方式push 。

huruzun@huruzun-All-Series:~/learngit$ git remote rm origin
huruzun@huruzun-All-Series:~/learngit$ git remote add origin [email protected]:huruzun/learngit.git
huruzun@huruzun-All-Series:~/learngit$ git push origin

大家注意網址 [email protected]:huruzun/learngit.git 是我自己的,只需要改成自己網址即可,大家如果輸入我的網址是無法push 過來,因爲我沒有大家ssh public key。

關於git 使用教程大家可以參看寥雪峯老師網站git 教程,還是比較清楚易懂。git 教程

發佈了166 篇原創文章 · 獲贊 54 · 訪問量 37萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章