git记住用户名和密码
2017-04-17 11:06
369 查看
转载自:http://blog.csdn.net/qq_28602957/article/details/52154384
在使用Git时,如果用的是HTTPS的方式,则每次提交,都会让输入用户名和密码,久而久之,就会感觉非常麻烦,那么该如何解决呢?
Windows中创建以.开头的文件的方法:
1:新建test.txt记事本,然后另存为.git-credentials
2:使用git bash
创建完成后,在该文件中输入:
注:username对应你的用户名,password对应你的密码
然后再进入git bas
h中
store为永久存储,当然也可以设置临时的
默认为15分钟,如果想设置保存时间的话,可以输入:
这样就设置了一个小时的有效时间。
执行完后查看%HOME%目录下的.gitconfig文件,会多了一项:
[credential]helper=store
重新开启git bash会发现git push时不用再输入用户名和密码
如果已添加远程地址
最为简单的方式就是,直接在.git/config文件中进行修改,按如上格式,添加用户名和密码
在使用Git时,如果用的是HTTPS的方式,则每次提交,都会让输入用户名和密码,久而久之,就会感觉非常麻烦,那么该如何解决呢?
方式一:使用SSH,添加ssh key。
方式二:在全局中存储用户的账号密码,方式如下
在%HOME%目录中,一般为C:\users\Administrator,也可以是你自己创建的系统用户名目录,反正都在C:\users***中。创建.git-credentials文件。Windows中创建以.开头的文件的方法:
1:新建test.txt记事本,然后另存为.git-credentials
2:使用git bash
touch .git-credentials
创建完成后,在该文件中输入:
https://username:password@github.com
注:username对应你的用户名,password对应你的密码
然后再进入git bas
h中
git config --global credential.helper store
store为永久存储,当然也可以设置临时的
git config –global credential.helper cache
默认为15分钟,如果想设置保存时间的话,可以输入:
git config credential.helper ‘cache –timeout=3600’
这样就设置了一个小时的有效时间。
执行完后查看%HOME%目录下的.gitconfig文件,会多了一项:
[credential]helper=store
重新开启git bash会发现git push时不用再输入用户名和密码
方式三:单独对某个项目免密
如果还未添加远程地址,可以输入一下命令:git remote add origin https://username:password@git.oschina.net/diligentyang/ysy107lab.git
如果已添加远程地址
最为简单的方式就是,直接在.git/config文件中进行修改,按如上格式,添加用户名和密码
相关文章推荐
- Windows For TortoiseGit记住用户名密码的方法(store保存模式 )
- Windows Git Bash 记住用户名密码
- 在idea中设置记住git的用户名和密码
- 在windows下 git 记住用户名密码
- git 记住用户名密码
- git记住用户名和密码
- git之https或http方式设置记住用户名和密码的方法
- git for windows (又名 msysgit)如何记住用户名和密码
- git 的记住用户名和密码和一些常用
- git之https或http方式设置记住用户名和密码的方法
- windows下让git bash记住你的用户名和密码
- Git 记住用户名和密码
- MAC/Linux 下 Git 记住用户名密码
- Git提交记住用户名和密码
- Windows下让Git记住用户名密码(https)
- git记住用户名和密码
- Liux记住git用户名和密码
- Windows7如何让Git 客户端记住用户名与密码
- MAC记住 git的用户名密码
- git 记住用户名密码