git 需输入用户名和密码

460 阅读1分钟

克隆的HTTPS URL , 可以使用credential.helper(凭证助手)来记住Username和Password。

$ git config credential.helper store

$ git push https://github.com/owner/repo.git

Username for 'https://github.com': <USERNAME>

Password for 'https://USERNAME@github.com': <PASSWORD>


这样下次再git push时,就不用输入用户和密码了。


还可以设置记住时间:

git config --global credential.helper 'cache --timeout 7200' # 这里设置账号信息被记住7200秒,两个小时。