git命令行pull,push解决每次都输入用户名密码

有时候git明明已经配置了用户名和密码,但在项目中,有时候pull和push的时候却每次都要提示输入用户名和密码,很浪费时间。


可以这样解决:

1、在git bash命令行中输入   echo $HOME  查看git home路径。

2、进入home对应的路径中。

touch .git-credentials    创建.git-credentials

vim .git-credentials 编辑

在./git-credentials中加入以下文本 https://用户名:密码@github.com

(如果不确定,也可以不填写,直接执行下面的语句

git config --global credential.helper store


3、执行完上面的git命令后,在命令行正常执行pull ,push,如果是在以上操作完之后第一次执行pull push,需要输入一次用户名密码,以后不再需要输入。

第一次向新的URL输入用户名密码之后会发现 .git-credentials中追加了类似 https://username:[email protected]的内容。


vim查看home路径中的.gitconfig,会在之前

[user]
name =
**********

email=***********

的基础上多出

[credential]
helper = stor
e


你可能感兴趣的:(工具使用)