3

Github is about to cut me off from my Digital Ocean server next week, it seems I am using the wrong email, I have tried all the suggestions on Stack Overflow and nothing seems to work.

So I have my BitBucket account as rxxxr@gmail.com, I can access BitBucket and generate an app password, no problem.

However when I push to Git, I still get the warning message "You are using an account password for Git over HTTPS etc"

The problem appears to be that I am pushing to Git with the wrong credentials.
My Bitbucket account is rxxxr@gmail.com, but I am pushing to git using tim@nxxxd.com and then pulling Git to my server using rxxxr@gmail.com.

When I started remote working for Nxxxd, I had to use tim@nxxxd.com to push to their Git account, and my MacBook Air still uses this for git even though it should be using rxxxr@gmail.com for Git.

Every attempt to get rid of tim@nxxxd.com in Git or on my Mac seems to be ignored by Git: I want to push to git using rxxxr@gmail.com and the new app password - any suggestions?

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
Xi Niu
  • 41
  • 1
  • 3

3 Answers3

1

@VonC was almost right and helped with the new credentials, once I removed the old credentials it resolved. This required the lines:

git config --system --unset credential.helper

git config --global --unset credential.helper

Xi Niu
  • 41
  • 1
  • 3
  • 1
    That does not remove the old credentials. That just remove the credential helper. Which means Git will always ask for your credentials, since it no longer has any helper registered. – VonC Feb 28 '22 at 22:13
0

If you are using HTTPS, the wrong credentials are probably cached in your credential storage.

Check the value, from the local repository folder, of

git config credential.helper
xxx

Then, using a BitBucket HTTPS access token from the right account rxxr, store the token for that server:

printf "host=bitbucket.org\nprotocol=https\nusername=rxxr\npassword=BitBucketToken" | \ 
git-credential-xxx store

Check it has stored the right value with:

printf "host=bitbucket.org\nprotocol=https\nusername=rxxr" | \ 
git-credential-xxx get

You next push will use the right credentials.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • VonC, I am very grateful for your suggestion, I tried it and it returned correctly so github accepts the credentials. However after resetting the MacBook and pushing via PhpStorm the same message appears and tail ./.git/logs/refs/heads/master indicates it is still using tim@nxxxd.com. If it helps, the Git warning includes "Note, these credentials may have been automatically stored in your Git client and/or a credential manager such as Git Credential Manager (GCM)", and I am working from the command line. – Xi Niu Feb 27 '22 at 06:01
  • @XiNiu ok, what does `git remote -v` return, when executed in your local repository folder? – VonC Feb 27 '22 at 07:01
  • many thanks for continuing to help me out: ***MBP:family tim$ git remote -v origin https://bitbucket.org/r***r/family (fetch) origin https://bitbucket.org/r***r/family (push) So this is also correct. Git push is via the PhpStorm terminal, I do not know if this is relevant. – Xi Niu Feb 27 '22 at 10:46
  • @XiNiu So it is an HTTPS URL indeed. Does the push work (and only git log shows `tim@nxxxd.com`). Or do you still have a warning even though you are supposed to use a token? – VonC Feb 27 '22 at 14:06
  • Yes, the push always works, however the warning is still there telling me I have to change my git/bitbucket credentials by March 1 (tomorrow at time of writing) and the git log continues to indicate that I am still using the credentials of n***d.com. – Xi Niu Feb 28 '22 at 05:36
  • @XiNiu What does `printf "host=bitbucket.org\nprotocol=https" | git-credential-xxx get` return? Does it mention the wrong user. – VonC Feb 28 '22 at 08:39
  • The solution for this came (just in time) from Atlassian, see here: [link] (https://confluence.atlassian.com/bbkb/why-am-i-not-prompted-for-password-when-pushing-or-pulling-to-my-repositories-in-bitbucket-cloud-via-https-800293400.html#:~:text=The%20most%20likely%20reason%20for,c)%20for%20a%20specific%20repository) – Xi Niu Feb 28 '22 at 22:01
0

I solved my problem just by setting the git credentials for my repository :

git config user.name yourBitBucketUserName

git config user.password yourBitBucketAppPassword

Your Bitbucket username can be found under Account | Personal settings.

You can list git's settings with :

git config --list

Pierre C
  • 2,920
  • 1
  • 35
  • 35
  • That does not set git credentials. That only set git authorship (for when you create locally new commits). Those are not used at all when authenticating yourself to the remote Git repository hosting service (like BitBucket). There is no such settings as [`user.password`](https://git-scm.com/docs/git-config#Documentation/git-config.txt-username), as [reminded here](https://stackoverflow.com/a/69535182/6309). – VonC Mar 16 '22 at 06:54