Git

push到github时每次都要输入用户名和密码的问题

Posted by lan_cyl on August 19, 2016

问题

在github上建立一个小项目,可是在每次push的时候,都要输入用户名和密码,很是麻烦

原因

关键是你用了https,它不走ssh通道,所以key 都没用了,https 保存密码可以参考,如果要ssh+key 无需密码提交,远程分支需要是ssh协议的 git@github.com:xx/xx.git

解决

1.查看远端的连接方式

git remote -v
;; 查看当前的远端连接
;; 输出如下:
;; origin	git@github.com:lan-cyl/lan-cyl.github.io.git (fetch)
;; origin	git@github.com:lan-cyl/lan-cyl.github.io.git (push)

2.移除旧的origin

git remote rm origin

3.添加新的ssh方式的origin

git remote add origin git@github.com:lan-cyl/lan-cyl.github.io.git

4.提交下试试

git push origin master

参考:


Creative Commons License
This work is licensed under a CC A-S 4.0 International License.