So, basically what you are say is when you run the following command you get asked for your username and password?
git clone -c http.extraHeader='Authorization: Bearer MDM0MjM5NDc2MDxxxxxxxxxxxxxxxxxxxxx' https://example.com/scm/projectname/teamsinspace.git
Bitbucket's repository access tokens (and Personal Access Tokens) are designed to be used in place of a username/password combination. The git clone
command, when presented with a URL without credentials, defaults to prompting for a username and password.
A way we can solve this is by embedding the token directly into the URL using the following format. That way it should look like this:
git clone https://x-token-auth:<your_token>@example.com/scm/projectname/teamsinspace.git
If you didn't know, x-token-auth
is a special username that signals to Bitbucket that you're using token-based authentication. It's not your actual Bitbucket username. Think of it as a placeholder.
If we were doing suggestions here, I'd say it's explicit and clear. It avoids any potential issues with how different Git versions or operating systems handle http.extraHeader
. It's the most commonly recommended approach in Bitbucket's own documentation when you look closely.
But overall, I think the best way to fix this is to embed the token directly in the URL using the https://x-token-auth:<your_token>@example.com...
format. For long-term convenience, use Git Credential Manager (GCM). Avoid the plain-text store
helper.