HOME,一般为C:\users\Administrator,也可是你自己创建的系统用户名目录,反正都在C:\users\中。演示为gitee(同理方式)
需要创建一个.git-credentials文件,由于在Window中不允许直接创建以"."开头的文件,所以需要借助git bash进行,步骤如下:
打开并编辑:vim .git-credentials(i-进入编辑模式)
编辑内容:https://{username}:{password}@gitee.com(登录账号,邮箱和密码)
保存编辑内容:按<ESC>键退出编辑模式,:wq <回车>保存并退出
git config --global credential.helper store
git config --global credential.helper store 打开%HOME%目录下的.gitconfig文件,会发现多了如下内容:
[credential]
helper = store
以上配置好后,关闭git bash重新打开,之后pull一个项目,首次还是要输入用户名及密码,之后pull成功后,再以后pull和push都不需要在输入用户名及密码了,此后打开新建的.git-credentials文件发现在https://{username}:{password}@gitee.com之上多了一条类似的文本。
基本步骤和上面类似,就是linux下面可以直接创建.git-credential文件,命令如下:
创建文件,进入文件,输入内容:
cd ~
touch .git-credentials
vim .git-credentials
https://{username}:{password}@github.com
在终端下输入:
git config --global credential.helper store
打开~/.gitconfig文件,会发现多了一项:
[credential]
helper = store
本地Windows下还可以通过添加环境变量来配置,参考网址:https://www.cnblogs.com/ballwql/p/3462104.html