remote:无效的用户名或密码。致命:认证失败

mrs*_*nes 5 git macos terminal github

我刚开始使用Git / Github,但我完全陷入困境。我在Mac / OSX El Capitan上使用Terminal,当要求输入密码时,它告诉我该密码无效,但是我输入的密码与我为GitHub帐户创建的密码相同,因此确定该密码有效吗?我究竟做错了什么?

Last login: Sun Dec  4 10:46:35 on ttys000
Seans-MBP:~ mrseanbaines$ git push -u origin master
Username for 'https://github.com': mrseanbaines
Password for 'https://mrseanbaines@github.com': 
remote: Invalid username or password.
fatal: Authentication failed for 'https://github.com/mrseanbaines/cartwheeling-kitten.git/'
Seans-MBP:~ mrseanbaines$
Run Code Online (Sandbox Code Playgroud)

kam*_*yFC 28

在 GitHub 上启用 2 因素身份验证 (2FA) 后,您将无法在命令行中使用 GitHub 密码。相反,您必须使用个人访问令牌。

个人访问令牌用于在个人应用程序和命令行上对您进行身份验证。命令行并没有告诉我们需要生成个人访问令牌,这就是为什么这个解决方案经常被程序员忽视的原因。

导航到“设置”页面点击侧边栏中的“开发者设置”点击侧边栏中的“个人访问令牌”点击“生成新令牌”填写表格以创建新令牌

使用该令牌作为密码和 git clone 将工作


小智 7

我曾经遇到过同样的问题。
解决方案:
步骤1:控制面板
步骤2:凭据管理器
步骤3:单击窗口凭据
步骤4:在“通用凭据”部分中,会有git url,编辑和更新用户名和密码步骤5:重新启动Git Bash并尝试克隆 在此处输入图片说明


nhu*_*uvy 5

(1)转到https://github.com/settings/security,关闭“双重身份验证”

(2)在新文件夹内创建一个新文件夹:

git clone https://github.com/mrseanbaines/cartwheeling-kitten.git
cd cartwheeling-kitten
Run Code Online (Sandbox Code Playgroud)

打开空的源代码目录,因为您使用的是macOS,请键入

open .
Run Code Online (Sandbox Code Playgroud)

(3)将您的源代码复制到cartwheeling-kitten文件夹(这是开始文件夹)

(4)配置

git config user.name "Your full name"
git config user.email "Your_email_address_what_used_to_register Github_account"
Run Code Online (Sandbox Code Playgroud)

(5)添加远程URL

git remote add upstream https://github.com/mrseanbaines/cartwheeling-kitten.git
Run Code Online (Sandbox Code Playgroud)

(6)加入舞台,然后按

git add -A .
git commit -m "Upload source code"
git push -u origin master
Run Code Online (Sandbox Code Playgroud)

(7)转到https://github.com/mrseanbaines/cartwheeling-kitten查看结果。


Fáb*_*uza 5

2020 - 当您在 Github 上更改密码并在本地计算机上更改密码时,它会抱怨凭据,但您可以轻松修复它,git pull这将强制询问您凭据。所以你输入新的并感到高兴:)。


yel*_*yed 0

确保您的远程 URL 正确。看来您缺少协议,它应该是:https://github.com/mrseanbaines/cartwheeling-kitten.git。您可以通过将存储库克隆到另一个目录并在那里尝试 git 操作来验证这一点。

如果你想修复它以添加协议,你可以这样做:git remote set-url origin https://github.com/mrseanbaines/cartwheeling-kitten.git