github最后一步Push报错
·
git.exe push --progress -- "origin" main:main
fatal: 已取消一个任务。
git: 'credential-manager-core' is not a git command. See 'git --help'.
git: 'credential-manager-core' is not a git command. See 'git --help'.
remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/long-lasting-dream/C.git/'
git did not exit cleanly (exit code 128) (149921 ms @ 2025/1/26 17:23:35)
这个报错信息表明在执行git push命令将本地main分支推送到远程仓库origin的main分支时出现了多个问题,具体分析如下:
credential-manager-core不是 git 命令:报错信息中提到 "git: 'credential-manager-core' is not a git command",这可能是因为 Git 配置了错误的凭证管理方式,或者相关的凭证管理工具没有正确安装或配置。在 Windows 系统上,Git 可能会尝试使用credential-manager-core来管理凭证,但如果它没有正确安装或者路径没有配置好,就会出现这个问题。- 密码认证已被移除:Github 从 2021 年 8 月 13 日起不再支持密码认证,报错信息中 "remote: Support for password authentication was removed on August 13, 2021." 明确指出了这一点。如果你的项目还在使用密码进行认证,就会导致认证失败。
- 认证失败:最终报错 "
fatal: Authentication failed for 'https://github.com/long-lasting-dream/C.git/'",结合前面的信息,主要原因是认证方式不被 Github 支持。
解决方案
- 生成并配置 SSH 密钥:
- 打开终端(在 Windows 上可以使用 Git Bash),运行以下命令生成 SSH 密钥
ssh-keygen -t rsa -b 4096 -C "你的邮箱地址"
- 按照提示操作,一路回车使用默认设置即可。
- 生成后,找到密钥文件,一般在
~/.ssh目录下(Windows 上在C:\Users\你的用户名\.ssh)。使用文本编辑器打开id_rsa.pub文件,复制里面的全部内容。 - 登录 Github,点击右上角头像,选择 “Settings”。在左侧菜单中选择 “SSH and GPG keys”,然后点击 “New SSH key”,将刚才复制的公钥内容粘贴到 “Key” 文本框中,添加即可。
- 将本地仓库的远程地址从 HTTPS 改为 SSH。如果原来的远程地址是
https://github.com/long-lasting-dream/C.git,可以使用以下命令修改:
git remote set-url origin git@github.com:long-lasting-dream/C.git
- 使用个人访问令牌(Personal Access Token):
- 登录 Github,点击右上角头像,选择 “Settings”。在左侧菜单中选择 “Developer settings”,然后选择 “Personal access tokens”,点击 “Generate new token”。
- 设置令牌的权限(根据实际需求选择,一般至少要勾选
repo相关权限),然后生成令牌。生成后复制令牌内容(注意,生成后只会显示一次,要妥善保存)。 - 在执行
git push等需要认证的操作时,在要求输入密码的地方输入这个个人访问令牌。如果是在命令行中操作,当提示输入密码时,粘贴令牌即可。
- 修复凭证管理问题(如果有需要):
- 如果是 Windows 系统,可以尝试重新安装或修复 Git 凭证管理器。可以在命令行中运行以下命令安装 Git 凭证管理器:
git config --global credential.helper manager-core
-
- 如果已经安装但有问题,可以尝试卸载后重新安装。卸载可以通过控制面板中的 “程序和功能” 找到 “Git Credential Manager Core” 进行卸载,然后重新运行上述安装命令。
- 对于其他系统,可以检查
git config --global credential.helper的配置是否正确,如果不正确,可以使用git config --global --unset credential.helper先取消错误的配置,然后根据系统和需求重新配置合适的凭证助手,比如git config --global credential.helper store(将凭证存储在本地文件中,不推荐在共享设备上使用) 。
更多推荐
所有评论(0)