Git , TortoiseGit 操作记住密码

 $ git config --global user.name "John Doe"$ git config --global user.email johndoe@example.com


在GitBash中 输入 git config --global credential.helper store 
执行完后去查看 %HOME%\.gitconfig 这个文件,发现多了一项: 
[credential] 
helper = store 



1. 创建存储用户名密码的文件 
在home文件夹 (Windows 直接 win + R 然后输入"%HOME%" 回车),新建名为 _netrc的文件, 里面的内容是: 

machine github.com
login alex.gao@ucweb.com
password 102030


2. 新建名字是  .git-credentials的文件
(如果是 windows请注意, win 下不允许直接创建以 . 开头的文件,所以先创建一个文件名叫 git-credentials 的文件)
然后在gitbash / 命令行 cd 到%HOME%这个目录, 执行: 

mv git-credentials .git-credentials 

用记事本打开这文件输入,如果用户名中有@,那么使用%代替: 


https://{username}:{password}@github.com 

比如: 
https://zhangsan%ucgit.com:123456@github.com 
保存 


3. 在GitBash中 输入 git config --global credential.helper store 
执行完后去查看 %HOME%\.gitconfig 这个文件,发现多了一项: 
[credential] 
helper = store 


三个文件如下



重新打开bash 或者使用tortoiseGit就不需要输入用户名密码了

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值