Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to clone an azure dev ops git repo using PAT with command line git or sourcetree?

Tags:

git

azure

ok, our org has the code in an azure dev ops repo.

I have been trying to clone it via git command line on the mac, via sourcetree on the mac and via sourcetree on windows, with no luck.

I created a PAT in the azure git web UI.

on the mac, if I do:

$ git clone https://ourorg.visualstudio.com/CMS/_git/ourProj
Cloning into 'ourProj'...
Username for 'https://ourorg.visualstudio.com': xxx
Password for 'https://[email protected]': 
fatal: Authentication failed for 'https://ourorg.visualstudio.com/CMS/_git/ourProj/'

For user, I tried my azure user, and I also tried the PAT. For pass, I tired my azure pass, and also the PAT.

None of these options work.

For sourcetree, I have also tried these combinations o PAT/PAT user/PAT user/pass etc. with no luck. Any suggestions?

This is the page I used to create the PAT:

https://learn.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=azure-devops

This doc says to use the PAT as the user and pass, but this simply doesnt work.

the doc also says you can do this:

git clone https://anything:{yourPAT}@dev.azure.com/yourOrgName/yourProjectName/_git/yourRepoName

But this does not work either.

e.g. If I do this (fixed thanks to jessejouwing):

$ git clone https://asdf:{myPATgoesHERE}@dev.azure.com/ourorg/CMS/_git/ourProj

On windows I always get:

Cloning into 'ourProj'... fatal: Authentication failed for 'https://dev.azure.com/ourorg/CMS/_git/ourProj/'

The PAT is 100% correct.

Unfortunately, "alternative credentials" is disabled in our org, so we have to use PAT. PAT is not working, so I cant work.

like image 591
John Little Avatar asked Sep 14 '25 09:09

John Little


2 Answers

git clone https://{yourPAT}@dev.azure.com/yourOrgName/yourProjectName/_git/yourRepoName

That should suffice.

like image 63
dparkar Avatar answered Sep 15 '25 23:09

dparkar


Just click on Generate Git Credentials and use it to authenticate / clone your repo:

enter image description here

like image 31
Thiago Custodio Avatar answered Sep 15 '25 23:09

Thiago Custodio