如何解决git [bitbucket]出现fatal: Authentication failed错误

8

最近我在使用" Tower "和"Sourcetree"等客户端时,遇到了一些问题。之前一切顺利,但是我把macOS更新成Mojave后,出现了以下错误:

错误详情: fatal: Authentication failed for 'https://username@bitbucket.org/sample/sample.git/'

请帮我查看并解决这个问题,谢谢!


1
你能通过浏览器登录吗?你具体使用了哪个命令? - Christoph
是的,我能够通过浏览器登录。我甚至在终端上使用了这个命令“git credential fill”,并在此模板中输入了信息:$ git credential fillprotocol=https host=(https://bitbucket.org/sample/sample.git) username=user123 password=pass123 - Muhammad Hamed K
哪个模板?请展示 git remote show origin 的结果(您可以编辑您的问题!) - Christoph
当我执行“git remote show origin”命令时,它会要求输入密码,我输入密码后,终端会显示origin分支。 - Muhammad Hamed K
那么您需要展示导致上述错误的确切命令序列(和输出)。否则我无法提供帮助。 - Christoph
显示剩余2条评论
3个回答

9
相同的错误(Windows,Git Bash命令行,bitbucket)。使用https(而不是ssh),应该提示输入登录凭据,但实际上出错了:
$ git pull origin master
fatal: Authentication failed for 'https://bitbucket.../my_git_project.git'

$ git config -l
...
credential.helper=manager
...

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

git pull 现在需要输入用户名和密码。


比原先被接受的答案更好、更清晰的答案。 - Ram Ghadiyaram

4
你可以尝试这个解决方案:
git remote add origin https://{username}:{password}@github.com/{username}/project.git

1
这将在明文的 gitconfig 文件中保存您的秘密用户名/密码。OP 应该使用凭据管理器,并需要升级到最新版本。 - Philip Oakley
同意@Philip的观点。用户名/密码也会以明文形式出现在您的shell历史记录中。应该避免这种情况发生。 - baelx

0

我解决了删除源并添加源的问题。之后,我在macOS Mojave中使用Tower和Sourcetree工具。在这之后,我遇到了一个问题,就是当我从源中获取时,没有一个跟踪的分支更新状态。我只需删除分支的跟踪,然后再次添加跟踪即可。之后一切正常。 - Muhammad Hamed K

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接