github - github个人访问令牌问题
问题描述
我正在尝试设置和使用 GitHub 个人访问令牌。
我查看了https://docs.github.com/en/get-started/getting-started-with-git/managing-remote-repositories#switching-remote-urls-from-ssh-to-https我可以我运行时返回的 https URLgit remote -v
当我尝试推送时,我得到一个 GitHub 登录提示。
我关闭它并得到一个 OpenSSH 提示。
我关闭它并输入我的用户名并获得另一个 OpenSSH 提示输入我的密码。
我关闭它并放入我的个人访问令牌,但这仍然不起作用。
根据第一个链接,我应该只被提示输入用户名和令牌。还有什么我需要做的吗?我在 Windows 上。
当我在 Linux (Ubuntu) 上尝试时,我只是提示用户名和密码,并且令牌有效。
解决方案
如果您在 Windows 上(使用最新的Git For Windows),并且确实在 上看到 HTTPS URL git remote -v
,则提示不应是 OpenSSH 提示。
确保您git config credential.helper
的设置为manager-core
.
然后 git push 应该询问您的凭据,您可以在其中使用您的令牌作为密码。
或者:OP tschumann通过删除凭证助手使其工作。
为了确保没有缓存凭据,我更喜欢:
- 检查
C:\Program Files\Git\mingw64\libexec\git-core
在我的%PATH%
- 仔细检查 Windows 凭据管理器中存储的内容
那是:
printf "host=github.com\nprotocol=https"|git-credential-manager get
如果您看到错误的密码,请使用以下命令将其删除
printf "host=github.com\nprotocol=https"|git-credential-manager erase
重复擦除命令,直到看到弹出窗口(不要输入您的凭据)
然后执行git push
, 并输入您的凭据以存储它们。
OP tschumann在评论中确认:
git config --global core.askPass ""
最终解决了这个问题
推荐阅读
- maven - maven中的repos没有jar文件吗?
- apache-spark - 如何在执行启动器中指定 spark 版本
- rxjs - 具有自定义创建逻辑的 RxJS BehaviorSubject
- c# - 为特定区域自定义 wpf 日历
- android - 如何获取当前播放音乐的详细信息?
- javascript - AmChart:隐藏事件
- python - Matplotlib | 开放式简历 | 内存优化
- azure-active-directory - Azure AD - 无需 B2C 即可注册
- c# - C# 不连接到数据库 (SQL)
- docker - docker push:未授权:客户端无权推送到仓库