git避免每次输入密码

生成公匙

在仓库所在目录输入

ssh-keygen -t rsa -C "yourname@sina.com"

其中yourname@sina.com是注册邮箱.可以在%HOME%.ssh下生成公匙id_rsa.pub. 将公匙粘贴到git网站上.

设置ssh

在仓库所在目录输入git remote -v,如果输出是类似以下内容

origin  git@git.oschina.net:test/django.git (fetch)
origin  git@git.oschina.net:test/django.git (push)

则说明是ssh方式.可以直接进行push之类操作,不用再输入密码.
如果输出是类似如下内容

origin  https://git.oschina.net/test/django.git (fetch)
origin  https://git.oschina.net/test/django.git (push)

刚说明不是ssh方式.要修改成ssh方式.命令如下

git remote rm origin
git remote add origin git@git.oschina.net:test/django.git
git push origin

之后就不用再输入密码了.

原文地址:https://www.cnblogs.com/zhouyang209117/p/6906384.html