windows:
1、在windows中添加一个HOME环境变量,变量名:HOME,变量值:%USERPROFILE%
2、进入%HOME%目录,新建一个名为"_netrc"的文件,文件中内容格式如下:
machine {git account name}.github.com login your-usernmae password your-password
重新打开git bash即可,无需再输入用户名和密码。
linux:
1、cd到git仓库目录
2、打开git配置文件:vim .git/config
3、在.git/config中添加以下配置项:
#将认证信息缓存到内存
[credential]
helper = cache --timeout 864000
#将认证信息保存到磁盘
[credential]
helper = store --file /home/work/.git-credentials
4、编辑 /home/loginuser/.git-credentials 文件为以下内容:
https://your-username:your-password@{git account name}.github.com
5、编辑 /home/loginuser/.netrc 文件为以下内容:
machine git域名 login 用户名 password 密码