git 帐号密码过时

git帐号密码过时了,在gitlab上修改后,本地还没进行同步时,链接远端仓库,报了这个错
image.pnggit

解决

  • 清空本地保存的用户名、密码(须要管理员身份)
git config --system --unset credential.helper
  • 此时重连会提示输入用户名密码
  • 从新配置用户名密码
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
  • 发现每次都会要求输入用户名密码,设置将凭证存起来
git config --global credential.helper store

不想用命令行,也能够直接手动修改配置文件。
image.png缓存

解析

git 配置文件

git 有多个范围(scope)的的配置文件,范围小的,覆盖范围大的
通常有system、global、local、worktree
存放目录以下:gitlab

scope location filename
system <git-install-root>\etc\,如:C:\Program Files\Git\etc\ gitconfig
global C:\Users\<username>\ .gitconfig
local <git-repo>.git\ config
worktree 同上 config.worktree

查找Git配置文件

记不住配置了哪些scope,能够使用如下命令查看全部的git配置文件spa

git config --list --show-origin

详细地列出配置内容和配置文件路径命令行

image.png

与下面命令不一样的是,下面命令只显示配置信息,不显示路径code

git config --list

image.png

git 凭证存储

git 若是是经过http访问远程仓库,须要输入用户名和密码,此时,若是不将凭证存储,则须要一遍一遍地输入用户名密码。blog

git config credential.helper "$helper $options"
模式 存储时长 存储位置
不缓存【默认】 -- --
cache 15min 内存
store 永久 磁盘
[其余] -- --
相关文章
相关标签/搜索