简体   繁体   English

如何使用带有命令行 git 或 sourcetree 的 PAT 克隆 azure 开发操作 git 存储库?

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

ok, our org has the code in an azure dev ops repo.好的,我们的组织在 azure 开发操作存储库中有代码。

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.我一直试图通过 Mac 上的 git 命令行、mac 上的 sourcetree 和 windows 上的 sourcetree 克隆它,但没有成功。

I created a PAT in the azure git web UI.我在 azure git web UI 中创建了一个 PAT。

on the mac, if I do:在mac上,如果我这样做:

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

For user, I tried my azure user, and I also tried the PAT.对于用户,我尝试了我的 azure 用户,我也尝试了 PAT。 For pass, I tired my azure pass, and also the PAT.为了通过,我厌倦了我的 azure 通行证,还有 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.对于 sourcetree,我也尝试了这些组合 o PAT/PAT user/PAT user/pass 等,但没有运气。 Any suggestions?有什么建议么?

This is the page I used to create the PAT:这是我用来创建 PAT 的页面:

https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=azure-devops https://docs.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.该文档说使用 PAT 作为用户并通过,但这根本不起作用。

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.但这也不起作用。

eg If I do this (fixed thanks to jessejouwing):例如,如果我这样做(感谢 jessejouwing 修复):

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

On windows I always get:在 windows 我总是得到:

Cloning into 'ourProj'... fatal: Authentication failed for ' https://dev.azure.com/ourorg/CMS/_git/ourProj/ '克隆到“ourProj”... 致命:“ https://dev.azure.com/ourorg/CMS/_git/ourProj/ ”的身份验证失败

The PAT is 100% correct. PAT 是 100% 正确的。

Unfortunately, "alternative credentials" is disabled in our org, so we have to use PAT.不幸的是,我们的组织中禁用了“替代凭据”,因此我们必须使用 PAT。 PAT is not working, so I cant work. PAT 不工作,所以我不能工作。

Just click on Generate Git Credentials and use it to authenticate / clone your repo:只需单击 Generate Git Credentials 并使用它来验证/克隆您的 repo:

在此处输入图像描述

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

That should suffice.这应该足够了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM