window 使用git 非ssh key 面密码登录

时间:2022-03-18 19:55:49

Windows下使用git bash时,总是提示输入用户名密码,严重影响了开发效率,经搜索查找找到了如下有效的解决方案,屡试不爽!


1、先创建存储用户名密码的文件 ,在home文件夹,一般是 C:\Documents and Settings\Administrator下建立文件.git-credentials(windows下不允许直接创建以.开头的文件,所以有一个小技巧:先创建一个文件名叫 )git-credentials 然后进入 git bash 使用命令:

mv git-credentials .git-credentials

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

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

例:https://wangshunyao:[email protected] 
保存;

3、重新进入 git bash,然后输入:

git config –global credential.helper store

执行完后去查看 C:\Documents and Settings\Administrator\.gitconfig 这个文件,发现多了一项: 
[credential] 
helper = store

就成功了。

4、然后要重新打开 git bash 窗口,再操作就不用输入用户名密码了

window 使用git 非ssh key 面密码登录