'remote: Unauthorized fatal: Authentication failed Bitbucket

Ok, so Here's the scenario,

I had user1 logged in to my terminal for bitbucket account.

I had logged in like

$ git config --global user.name "user1"
$ git config --global user.email "[email protected]"

I was able to do commit and push perfectly.

Now I had another account on bitbucket with another email id for user2.

So I logged in like:

$ git config --global user.name "user2"
$ git config --global user.email "[email protected]"

But now when I am doing git push origin master I am getting the below error.

fatal: Authentication failed for 'https://[email protected]/user3/test.git/'

So I completely uninstalled git from my Ubuntu 14.04 and installed it again and logged in again. But even then getting the same issue.

How to avoid that error message?



Solution 1:[1]

The user.name and user.email local config have nothing to do with git repos hosting server authentication. It is just for committer/authorship on commits.

If you are using an https url, that means you need to use the BitBucket login and password.
If there is a BitBucket account 'user2', then its BitBucket password will be enough to pass the authentication (he/she will need to be a collaborator in user3 project in order to have the right to push though)

Make sure there is no special character in the password, or you would have to percent-encode it.

Solution 2:[2]

I faced the same problem! Even after providing correct password it showed the same error.

Solution

Step:Just check your pass is correct. if it is OK then check you have the correct permission on that repository. (i got permission problem and solved using the step)

Solution 3:[3]

My problem was that I was using https instead of ssh, after that change everything worked for me.

Solution 4:[4]

I had similar issue, in one of my computers. I and was able fix the problem by commenting/removing these lines in the file ~/.gitconfig

[url "https://:@repo.zzz.xxx"]
insteadOf = https://repo.zzz.xxx

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Community
Solution 2 Helping Hands
Solution 3 StefanAcim98
Solution 4 coder