106

I use BitBucket and had to change my password because it was compromised.

git pull

remote: Invalid username or password. If you log in via a third party service you must ensure you have an account password set in your account profile.
fatal: Authentication failed for 'https://bitbucket.org/myusername/myproject.git/'

How can I change my password using command line?

Andrejs Cainikovs
  • 27,428
  • 2
  • 75
  • 95
software is fun
  • 7,286
  • 18
  • 71
  • 129

20 Answers20

194

You need to reset the password as shown below.

On macOS:

git config --global credential.helper osxkeychain

On Windows 10/11:

git config --global credential.helper store

After executing this, it prompts you for the user name and password for your repo.

software is fun
  • 7,286
  • 18
  • 71
  • 129
  • 6
    This frustrated me for 2 hours before I realized I had to restart in order to trigger Git to prompt me for the username and password. – incandescentman Jun 15 '16 at 02:56
  • but where should i put it cause i am using plugin of bitbucket can u guide me?? – Vishal Patel Nov 22 '16 at 08:18
  • Nice! So now I can enter my Atlassian password instead of my old BB password (ugh) – sglessard Nov 25 '16 at 18:41
  • 1
    This problem has nothing to do with Bitbucket or sourcetree, but rather with git itself. Try command if you are using git on linux terminal: git config --global --unset credential.helper – tutiplain Jul 15 '18 at 11:27
60

I think is only an authentication problem...

  1. Click on your Bitbucket account icon (up right) and go to "Manage account".
  2. Go to "Change password" option in left menu.
  3. Enter your password in "New password" and "Confirm password" fields.
  4. Click on "Change password".

That's all :)

David Motilla
  • 775
  • 1
  • 4
  • 5
  • 1
    Yes, actually when i faced with this "If you log in via a third party service you must ensure you have an account password set in your account profile." I just changed my password in settings and everything now works – Mikhail Valuyskiy Jan 29 '16 at 12:43
  • 3
    This did not work for me. I had reset the password already but my cmd line was not giving me an ability to enter my new password. – Sam Alexander Feb 22 '16 at 20:16
  • 3
    my Extention: after New password was set you have to make Logout and Login to Bitbucked.org (not Atlassian!!!). After this you have to update password on your side (Xcode, SmartGit etc.) and everything will be OK. – Włodzimierz Woźniak Dec 01 '16 at 10:54
  • Actually, I just change my account password in web client in bitbucket last night, then I encountered this issue... – Itachi May 12 '17 at 04:11
  • Really need to change the password in order to remove the authentication error. It's working now. – Eddy Goh Aug 29 '17 at 05:59
  • The solution is obsolete. A password reset is possible via a [web form](https://bitbucket.org/account/password/reset) – jaam Jun 04 '18 at 12:11
  • Thanks, couldn't get it to work until I changed my password at Atlassian. It kept complaining my initial password was invalid (new user) but changing it solved it. – Hugo Delsing Jun 04 '18 at 14:29
50

First, edit your .git/config and remove your username from 'url'.

I had this:

url = https://username@bitbucket.org/pathto/myrepo.git

And after modification:

url = https://bitbucket.org/pathto/myrepo.git

Then try to pull (or push) and use your email and password credentials to login.

Guille Acosta
  • 2,051
  • 23
  • 35
  • 1
    I did this but the url change did not show when I tried to push. After doing a pull I got a login screen and subsequently I was able to push, however the old url with the user name still displays in the push dialog – Kirsten Jan 13 '17 at 23:30
  • 1
    This worked for me. Using SourceTree go to settings in the top right, Remotes, and then edit the url path. – Steven Carlton Feb 21 '17 at 02:43
  • 5
    Thanks! This trick actually worked. After fetching, I had to re-enter my login (email) and password, and it finally worked again. – drilboor Nov 02 '17 at 11:27
31

Lately, BitBucket needs you to generate an App Password:

Settings/Access Management/App Passwords.

https://bitbucket.org/account/user/.../app-passwords

Alin Porumb
  • 311
  • 3
  • 3
22

If you are a mac user this worked for me:

  1. open Keychain Access.
  2. Search for Bitbucket accounts.
  3. Delete them.

Then it will ask you for the password again.

sergiosua
  • 364
  • 2
  • 4
  • I know it may be off topic, but I use SourceTree, and found this thread helpful. BUT I needed to also remove my account in the SourceTree app, and then enter it again, in addition to removing the entries in the System KeyChain. – Clausen Jan 17 '18 at 09:30
15

I needed to do this and run a git pull in order to set my password from the command line in order to get this working.

Note this method saves your password in a plain text file on your disk:

git config --global credential.helper store
git pull

Other solutions here: Is there a way to skip password typing when using https:// on GitHub?

Community
  • 1
  • 1
dtbarne
  • 8,110
  • 5
  • 43
  • 49
10

I clicked on this button and it worked for me.

Here is the screenshot

ɢʀᴜɴᴛ
  • 32,025
  • 15
  • 116
  • 110
Raja Islam
  • 119
  • 1
  • 2
  • 2
    Don't just use a picture. Describe *what button* you clicked and, of course, why you expect that to be useful for this. – Nathan Tuggy Jul 25 '17 at 03:55
8

If you've changed the password on Windows 10, go to credential manager and update the password:

go to credential manager and update the password

double-beep
  • 5,031
  • 17
  • 33
  • 41
dev adgh1
  • 129
  • 1
  • 4
6

You can update your Bitbucket credentials from the OSX Keychain.

Updating your cached credentials via the command line:

$ git credential-osxkeychain erase
host=bitbucket.org
protocol=https
[press return]

If it's successful, nothing will print out. To test that it works, try and clone a repository from Bitbucket. If you are prompted for a password, the keychain entry was deleted.

ricardopereira
  • 11,118
  • 5
  • 63
  • 81
5

If you found authentication error problem when you entered correct password and username it's git problem. To solves this problem when you are installing the git in your machine uncheck the enable git credential manager enter image description here

Hoque MD Zahidul
  • 10,560
  • 2
  • 37
  • 40
3

I was facing same error, But I didn't need to change my password.

Just go to bitbucket->preferences->accounts select your account and check if your password is correct.

In my case, my password was messed up. Just corrected my password and it worked.

Ali Sajid
  • 257
  • 2
  • 12
3

This answer is for SO users who browse here after searching for the error.

  • Terminal will not accept your Bitbucket or Atlassian web app password if
    your account is associated with an Atlassian (Jira) account. If this is your case, you have a giant string generated for you that you can find in your MacOSX keychain app. This is the password Terminal accepts.
  • It is not clear how to re-generate this password or re-set it to match what Bitbucket will accept.
  • Changing password in SourceTree's settings did not work for me.
  • Changing password in Atlassian account profile did not work for me.
  • Bitbucket does not have a link or interface to change password for this case in the Bitbucket account profile - user has to go to Atlassian account profile.

In my case, nothing worked because I changed my username in Bitbucket.

Atlassian and Bitbucket are not completely integrated. Bitbucket uses the Atlassian user email and web app password, but allows you to have a different username.

There seems to be a bug in this process, especially since it's not clear which application or process is generating the authentication and where it's stored or editable. Changing the username breaks authentication.

There may be a way to update the username used by the credentials and Bitbucket, but I was already several hours behind when I discovered that changing my username back to what it was before restored authentication.

Deborah
  • 4,316
  • 8
  • 31
  • 45
3

For me the issue was I changed my username so the git url also got changed. So I had to set the new git url using

git remote set-url origin <URL>
pritesh
  • 2,162
  • 18
  • 24
3

Sometimes it happens when you change the remote bitbucket account password.

Solution

Go to Control panel => User Accounts => Credential Manager => Windows Credentials => move to Generic credentials and change the password of account
1
  1. Firstly reset your password at "https://id.atlassian.com"
  2. Ensure you are able to login to Bitbucket Cloud - "https://bitbucket.org"
  3. Clear stored credentials on your machine a. Windows: Navigate to Credential Manager and clear stored credentials related to Bitbucket Cloud.
  4. Mac OS X: Navigate to Keychain Access and clear stored credentials related to Bitbucket
  5. Cloud Once this is done, try to login to perform a git operation authenticating to Bitbucket Cloud once again.
Nipun Garg
  • 11
  • 2
1

I was facing the issue on Windows 10 after changing my password for bitbucket. I just opened git bash in my repo location; Wrote command for

git push --set-upstream origin <branch_name>

It opened git credential manager window and asked for credentials. I entered the new one and it pushed successfully.

Al-Amin Sarker
  • 508
  • 3
  • 16
0

I know that this is an old question, but I thought I would provide the solution that worked for me. I signed up for bitbucket using my google account and did not have a password. Turns out the password is my Atlassian account password. If you have an Atlassian account then try this password to see if it works.

pg316
  • 1,380
  • 1
  • 8
  • 7
0

For myself only a combination of the approaches by @software-is-fun and @dev-adgh1 worked.

The cause was, that I changed my password (SSO) and did not use a token for our company repository. I am using Windows 10 and this is the only repository I wanted to have this authentication credentials be used.

So I did the following:

  1. Execute git config --local credential.helper store in the directory where my repository was located
  2. Erase the file %USERPROFILE%\.git-credentials, so eg c:\users\username.git-credentials (have a look at it first to not throw your other credentials away)
  1. Open the Windows Credential Manager, Open Windows Credentials, Delete the credentials for the repository in use
  2. Execute a git pull in your local repository directory and get prompted with the new login (where I entered my username and the token - not the password).

Working :)

Alexander Taubenkorb
  • 3,031
  • 2
  • 28
  • 30
0

This helps me.

Run git remote -v to see the current remote URL.

$ git remote -v
origin https://emmap1@bitbucket.org/tutorials/tutorials.git.bitbucket.org.git  (fetch)
origin https://emmap1@bitbucket.org/tutorials/tutorials.git.bitbucket.org.git  (push)

 

Update the remote URL with git remote set-url using the current and new remote URLs.

$ git remote set-url origin git@bitbucket.org:tutorials/tutorials.git

https://support.atlassian.com/bitbucket-cloud/docs/app-passwords/

Tuan Dao
  • 2,647
  • 1
  • 10
  • 20
-1

I solved it this way.

If you use sourcetree, go to tools->options->Authentication->Accouns Edit and Authentication OK. Then, when i tried again no problem.

Erman
  • 192
  • 1
  • 3
  • 14