解决git操作一直要求输入用户名和密码的问题


git每次pull、push都要求输入用户名和密码

解决方法: 保存用户本地凭证即可,这样每次git操作时,使用已保存的凭证就OK了。

1 ## 全局
2 git config --global credential.helper store
3 
4 git config --global user.username "username"
5 git confgi --global user.password "password"

 

1 ## local
2 git config --local credential.helper store
3 
4 git config --local user.username "username"
5 git confgi --local user.password "password"

顺便介绍下git config的其他一些用法:

在Git中用户名和密码是保存在gitconfig文件中的。这个文件有全局配置和本地配置,全局配置指的是Git所有仓库都适用的配置,本地配置指的是特定仓库适用的配置。--global credential.helper store命令告诉Git将用户名和密码存储在本地.git-credentials文件中。

如果我们已经配置了用户名和密码,那么我们可以使用以下命令来查看Git的配置信息:

git config --list

运行该命令后,会显示Git的所有配置信息,我们可以查看用户名、邮箱、用户名和密码等信息。

如果我们需要修改本地仓库的用户名和密码,可以使用以下命令来进行修改,命令会打开gitconfig文件,我们可以手动修改文件中的用户名和密码,保存后关闭文件即可。

git config --local --edit

 

posted @ 2023-05-24 11:15  Don  阅读(7109)  评论(0编辑  收藏  举报