You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何解决Windows版Git持续要求输入GitHub凭证的问题

Git HTTPS每次输入凭证的解决办法(适用于Git for Windows 2.40.0)

先清理混乱的全局配置

你的.gitconfig里存在冲突配置项,先逐个清除:

git config --global --unset credential.github.com.authority
git config --global --unset credential.github.com.interactive
git config --global --unset credential.github.com.preserve
git config --global --unset credential.modalPrompt
git config --global --unset credential.writelog

配置正确的凭证助手

Git for Windows 2.40.0默认使用Git Credential Manager (GCM),执行以下命令设置全局凭证助手:

git config --global credential.helper manager-core

重新存储PAT凭证

执行一个需要权限的Git命令触发凭证存储流程:

git fetch

此时会弹出GCM的登录窗口,选择「Personal access token」,输入你的GitHub用户名,把个人访问令牌粘贴到密码栏,完成验证后,凭证会自动存入Windows凭据管理器。

验证效果

执行git pull或git push,确认不再反复要求输入凭证。

补充说明

VSCode终端能正常工作是因为它自带凭证处理逻辑,会自动读取系统存储的凭证,但独立的Git Bash需要正确配置GCM才能复用这些凭证。

额外排查步骤

  • 打开Windows「凭据管理器」(控制面板→用户账户→凭据管理器→Windows凭据),找到git:https://github.com的条目,检查用户名和PAT是否正确,若有误则删除该条目后重新执行上述步骤。
  • 确认你的PAT没有过期,且具备仓库读写所需的权限(至少勾选repo权限)。

内容的提问来源于stack exchange,提问作者John London

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.25 13:22:18