git记住账号密码

来源:互联网 发布:四川理工学院知乎 编辑:程序博客网 时间:2024/05/16 01:57

涉及到记住密码的方式,只适用于http(s)方式,记住密码的几种方式:

https 方式每次都要输入密码,按照如下设置即可输入一次就不用再手输入密码的困扰而且又享受 https 带来的极速;

按照以下设置记住密码十五分钟:

git config --global credential.helper cache

如果你想自定义记住的时间,可以这样:

git config credential.helper 'cache --timeout=3600'

这里记住的是一个小时,如需其他时间,请修改3600为你想修改的时间,单位是秒
你也可以设置长期记住密码:

git config --global credential.helper store

或修改仓库的地址带上你的账号密码

http://yourname:password@git.oschina.net/name/project.git 

不推荐这种方式。

如果你原本使用的 ssh 地址想更换成 http(s) 地址,可以执行以下命令:

删除原本的ssh仓库地址

git remote rm origin 

origin 代表你原本ssh地址的仓库的别名。
新增http地址的仓库:

git remote add origin http://git.oschina.net/username/project.git

正经实用的git教程。
http://git.mydoc.io/?t=154710

原创粉丝点击