This issue was created by @JoseFMP from https://github.com/MicrosoftDocs/feedback/issues/833
roblem
There is beautiful documentation about the PATs in Azure DevOps and how nice and convenient they are.
However there is not even a single example on how to use them from the user perspective, i.e. there are examples on how to create them but not how to consume them. Not a single one.
Solution
It would be great to have at least a single example on how to consume the PATs to clone a git repo from Azure DevOps in the command line using the non-bloated raw git CLI NOT IN Windows.
⚠Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
Exactly, I've created a token in my AzureDevOps project , Then how can I used it in my IDE or Git?
Sorry for the frustration of this not being clear. To authenticate with the PAT while using Git, you can use it as the password. The username can be anything, since your identity is identified with the PAT. For example:
Username: anything
Password: <your PAT here>
Or:
git clone https://anything:<PAT>@dev.azure.com/yourOrgName/yourProjectName/_git/yourRepoName
@Powerhelmsman Thanks for your great suggestion. I've created a work item on my backlog to address this. Please let us know if you have any further questions. Thanks again.
Sorry for the frustration of this not being clear. To authenticate with the PAT while using Git, you can use it as the password. The username can be anything, since your identity is identified with the PAT. For example:
Username: anything
Password:<your PAT here>
Or:
git clone https://anything:<PAT>@dev.azure.com/yourOrgName/yourProjectName/_git/yourRepoName
I tried unsuccessful with: 😕
git clone https://anything:<PAT>@...
But work fine with: 😮😀
git clone https://<PAT>@...
When working with my company's private azure devops instance the correct syntax was:
https://<PAT>@<company_machineName>.visualstudio.com:/<path to git repo>
Where the path to the repo was <project name>/_git/<repo_name>
I hope this is helpful for someone. The syntax in the documentation is just wrong.
To add, for the lonely google surfer. For existing repos..
..if you've already added the origin, using the username.. run the following command first.
git remote remove origin
otherwise..
git remote add origin https://<PAT>@<company_machineName>.visualstudio.com:/<path to git repo>
git push -u origin --all
Hope this helps someone :)
@neilhighley Thank you!
More for the lonely googler, since I couldn't get neilhighley's format to work.
From Cannot clone git from Azure DevOps using PAT, using the format https://<PAT>@mydomain.visualstudio.com/myproject/_git/myrepo
works for me
@chcomley Can we reopen this? From your perspective, you might have other tools telling you that this is still being tracked, but from a user perspective, it only looks like we are being ignored. This should be trackable publicly.
Hi @MisinformedDNA, I've recently updated this article. Would you please verify whether it meets your needs now? I included some examples of using a PAT. If it doesn't, please let me know and I'll take another stab at it. Thank you.
Hi,
I am sailing in the same boat, @chcomley - can you please share the article details.
What I want to do -
Within Azure DevOps Pipeline, I want to pull and then push some files to Azure DevOps Git Repos
What I did -
I am using the following command under command Line task for Pipeline
git pull https://$(PAT)@dev.azure.com/OrgName/ProjectName/_git/repoName master,
where $(PAT) is coming from Variables
The error I am getting -
Logon failed, use ctrl+c to cancel basic credential prompt.
fatal: could not read Password for 'https://
What I have referred -
http://intranoggin.com/Blog/February-2017/Synchronizing-code-between-GitHub-and-VSTS.aspx.
Can you please help me out with some examples/ or let me know what's going wrong.
Thanks.
@chcomley Huge improvement! Thank you.
@hemantshriv I am experiencing the same issue. My script runs fine if I execute it locally, but gives me ''fatal: could not read Password for '[url]': terminal prompts disabled" if executed from pipeline.
I am trying to clone into RedHat JBPM and using
{PAT}@{server}.visualstudio.com:/{org}/{project}/_git/{repo} there is a timeout on the connect after about 30 seconds and with
{PAT}@{server}:/{org}/{project}/_git/{repo} I get
Caused by: org.eclipse.jgit.errors.TransportException: {PAT}@{server}:/{org}/{project}/_git/{repo : remote hung up unexpectedly
...
at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:243)
... 104 more
Caused by: java.lang.NullPointerException
at java.lang.String.
at org.eclipse.jgit.transport.CredentialsProviderUserInfo.promptPassword(CredentialsProviderUserInfo.java:121)
at com.jcraft.jsch.UserAuthPassword.start(UserAuthPassword.java:57)
Help?
@drdaveg Are you trying to do a git clone? If so, try this
MY_PAT=yourPAT # replace "yourPAT" with your actual PAT
B64_PAT=$(echo ":$MY_PAT" | base64)
git -c http.extraHeader="Authorization: Basic ${B64_PAT}" clone https://dev.azure.com/yourOrgName/yourProjectName/_git/yourRepoName
Hi all, does everyone have the information they need to be successful? Is there anything else that I should add to the article? Thanks!
I can confirm that using http.extraHeader solved the issue I was having.
Thanks for your reply, @badgerbaj, much appreciated. Glad your issue was solved. I'll be closing this issue, however if anyone else has any further feedback or follow up questions, feel free to @mention me. Have a nice day!
Most helpful comment
Sorry for the frustration of this not being clear. To authenticate with the PAT while using Git, you can use it as the password. The username can be anything, since your identity is identified with the PAT. For example:
Username: anything
Password:
<your PAT here>
Or: