在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 教程