Git记住用户名密码

在%HOME%目录中,一般为C:\users\Administrator,也可以是你自己创建的系统用户名目录,反正都在C:\users***中。创建.git-credentials文件。

Windows中创建以.开头的文件的方法:

1:新建test.txt记事本,然后另存为.git-credentials

示例

2:使用git bash

touch .git-credentials
 
 
  • 1

创建完成后,在该文件中输入:

https://username:password@github.com

注:username对应你的用户名,password对应你的密码

然后再进入git bash中

git config --global credential.helper store
 
 
  • 1

store为永久存储,当然也可以设置临时的

git config –global credential.helper cache
 
 
  • 1

默认为15分钟,如果想设置保存时间的话,可以输入:

git config credential.helper ‘cache –timeout=3600’
 
 
  • 1

这样就设置了一个小时的有效时间。

执行完后查看%HOME%目录下的.gitconfig文件,会多了一项:

[credential]helper=store

重新开启git bash会发现git push时不用再输入用户名和密码

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值