9

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 "user1@gmail.com"

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 "user2@gmail.com"

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

fatal: Authentication failed for 'https://user2@bitbucket.org/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?

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
Suraj
  • 2,423
  • 12
  • 39
  • 75

4 Answers4

2

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.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • I do have ! In my password. Could be this be the issue. Let me check – Suraj Jan 26 '16 at 09:19
  • Instead of ! I should use %21 ?? – Suraj Jan 26 '16 at 09:23
  • @Suraj Not if you type it directly (like, for instance, when you log in to BitBucket). Only if you use it in an url. – VonC Jan 26 '16 at 09:24
  • @Suraj if you use https://user:yourpassword%21@bitbucket.org/users/user3/test.git, then you would encode the password. But first: can you login to BitBucket through https://bitbucket.org/account/signin/?next=/account/ ? (using your password with a regular `!`) – VonC Jan 26 '16 at 09:27
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/101656/discussion-between-suraj-and-vonc). – Suraj Jan 26 '16 at 09:30
  • I am facing the same issue. Can you @VonC, tell me how can I solve this? I cannot read your chat further! – Jayna Tanawala Nov 13 '21 at 04:31
  • @JaynaTanawala That would be best addressed as a separate question, but the general approach these days (as opposed to 2016 when I write this answer) is to use an HTTP access token (https://confluence.atlassian.com/bitbucketserver/personal-access-tokens-939515499.html), as in https://stackoverflow.com/a/68598469/6309 – VonC Nov 13 '21 at 21:53
1

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

0

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)

Helping Hands
  • 5,292
  • 9
  • 60
  • 127
Nur Uddin
  • 1,798
  • 1
  • 28
  • 38
0

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
coder
  • 23
  • 8