主页

设置git凭据存储助手(credential.helper store)

2025-02-06 04:44PM

如果设置了git 凭据存储助手,git 会将你的凭据存储在一个文件中,以便下次自动使用,而不是每次都要求你输入用户名和密码

1. 可以使用 credential.helper cache 命令来临时存储凭据

$ git config --global credential.helper cache

如果需要,任何时间都可以通过以下方式删除缓存记录

$ git config --global --unset credential.helper
$ git config --system --unset credential.helper

2. 检查是否成功设置 git 的凭据存储助手

2.1 检查凭据文件

$ ls -a ~ | grep .git-credentials

2.2 查看其内容

$ cat ~/.git-credentials

2.3 进行首次拉取:

$ git pull

尝试再次运行 git pull,输入你的 GitHub 用户名和刚刚生成的 Personal Access Token(PAT)。

如果你成功拉取代码,凭据应该会被存储在 .git-credentials 文件中。  

2.4 .git-credentials 查看文件内容

$ cat ~/.git-credentials

https://666:gxxxxxxxxxxxxxxxxxxxxxxxxxxx@github.com 

发现确认凭据已经被正确存储啦~

返回>>

登录

请登录后再发表评论。

评论列表:

目前还没有人发表评论