8

I have been facing issue when i fetch or pull in any client. i.e "Tower" and Sourcetree. Everything was going smoothly , i did just update macos into Mojave.

But I always get

Error details: fatal: Authentication failed for 'https://username@bitbucket.org/sample/sample.git/'

Christoph
  • 6,841
  • 4
  • 37
  • 89
Muhammad Hamed K
  • 279
  • 1
  • 4
  • 9
  • 1
    Can you login via browser? What command did you exactly use? – Christoph Oct 12 '18 at 11:38
  • Yes i am able to login via browser. even i used this command on terminal "git credential fill" and put info in this template: $ git credential fill protocol=https host=(https://bitbucket.org/sample/sample.git) username=user123 password=pass123 – Muhammad Hamed K Oct 12 '18 at 11:40
  • Which template? Please show the result of `git remote show origin` (You can edit your question!) – Christoph Oct 12 '18 at 11:42
  • When i command "git remote show origin" it asked password i entered password then it shows origin branches at terminal – Muhammad Hamed K Oct 12 '18 at 11:57
  • Then you need to show the exact sequence of commands (and output) which lead to the error above. Otherwise I can't help. – Christoph Oct 12 '18 at 12:01
  • I did just remote origin, using terminal command "git remote remove origin" and then put command again "git remote add origin https://myusername@bitbucket.org/project/project.git" and now its fetching in Tower (MacOs Client). – Muhammad Hamed K Oct 12 '18 at 12:11
  • I did resolve that issue with removing origin and then add origin. after that i was using tower and sourcetree tools in macOsMojave. after this all, i was having issue like when i fetch from origin. not an single tracked branch was updating status. I just remove tracking of branches and then add tracking again. after that its working fine – Muhammad Hamed K Oct 17 '18 at 18:01

3 Answers3

9

The same error (Windows, Git Bash command line, bitbucket). Using https (not ssh) which should prompt for login credentials but instead errors:

$ 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 now prompted for username/password.

Vladislav Povorozniuc
  • 2,149
  • 25
  • 26
4

You can try this solution:

git remote add origin https://{username}:{password}@github.com/{username}/project.git
flik
  • 3,433
  • 2
  • 20
  • 30
  • 1
    This will save you secret username/password in the plain text gitconfig file. The OP should use a credential manager, and needs to upgrade to the very latest version. – Philip Oakley Oct 12 '18 at 12:20
  • Agree with @Philip. The username/password will also be in plain text in your shell history. This should be avoided. – baelx Nov 23 '21 at 17:45
0

The best approach is to use the Git Credentials Manager (https://github.com/Microsoft/Git-Credential-Manager-for-Windows/releases/tag/v1.18.1), or the appropriate cred manager for your OS. Don't put your username/password in the plain text config file (unless it is double blank..)

Philip Oakley
  • 13,333
  • 9
  • 48
  • 71
  • I did resolve that issue with removing origin and then add origin. after that i was using tower and sourcetree tools in macOsMojave. after this all, i was having issue like when i fetch from origin. not an single tracked branch was updating status. I just remove tracking of branches and then add tracking again. after that its working fine. – Muhammad Hamed K Oct 17 '18 at 17:53