简体   繁体   English

如何在 Azure DevOPS 服务器上使用 PAT 克隆 git 存储库

[英]How to use PAT on Azure DevOPS Server to clone a git repo

Hi we are trying to clone a git repo from our local Azure DevOps server 2020.0.1.您好,我们正在尝试从本地 Azure DevOps 服务器 2020.0.1 克隆一个 git 存储库。 We are using the command bellow, but it is not working.我们正在使用下面的命令,但它不起作用。 Should this be possible?这应该是可能的吗?
The documentation I try to follow is this .我尝试遵循的文档是this But it is a bit unclear.但是有点不清楚。

git clone https://{an username:yourPAT}@yourURL/yourOrgName/yourProjectName/_git/yourRepoName

We then get an error: "fatal: Authentication failed for "然后我们得到一个错误:“fatal: Authentication failed for ”
We also tried variations like 'yourname:yourPAT', 'yourPAT', ':yourPAT', 'yourPAT:' We want to use PAT's together with SmartGit我们还尝试了像 'yourname:yourPAT', 'yourPAT', ':yourPAT', 'yourPAT:' 这样的变体 我们想将 PAT 与 SmartGit 一起使用

We then tried to use the other method mentioned (but when reading this is only needed when using basic authentication, we never enabled this on our ADOS-server, and is also not an authentication method on our IIS-website:然后我们尝试使用提到的其他方法(但是当阅读时只有在使用基本身份验证时才需要,我们从未在我们的 ADOS 服务器上启用它,并且也不是我们 IIS 网站上的身份验证方法:

$MyPat = 'yourPAT'
$B64Pat = [Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes(":$MyPat"))
git -c http.extraHeader="Authorization: Basic $B64Pat" clone https://{yourURL/yourOrgName/yourProjectName/_git/yourRepoName

This one is working这个正在工作

The PAT we created is with full scope and access to all organizations.我们创建的 PAT 具有完整的 scope 和所有组织的访问权限。
The PAT is working to add an Agent. PAT 正在努力添加代理。
We can also use it to access the RESTAPI (with curl you should -u and random or empty username, so bla;yourPAT).我们还可以使用它来访问 RESTAPI(使用 curl 你应该 -u 和随机或空的用户名,所以 bla;yourPAT)。

Any advice is appreciated.任何建议表示赞赏。

Based on your description, when you use the basic auth to run the git command, it could work.根据您的描述,当您使用基本身份验证运行 git 命令时,它可以工作。

It seems that the basic auth is enabled.似乎启用了基本身份验证。

If you enable IIS Basic Authentication for Azure Devops server, PATs aren't valid.如果为 Azure Devops 服务器启用 IIS 基本身份验证,则 PAT 无效。 See Enabling IIS Basic Authentication invalidates using Personal Access Tokens .请参阅启用 IIS 基本身份验证使使用个人访问令牌无效

If you use Git with IIS Basic Authentication, Git breaks because it requires PATs for user authentication.如果您将 Git 与 IIS 基本身份验证结合使用,则 Git 会中断,因为它需要 PAT 来进行用户身份验证。 Although we don't recommend you use IIS Basic Authentication, by adding an extra header to Git requests, you can use Git with IIS Basic Authentication:虽然我们不建议您使用 IIS 基本身份验证,但通过向 Git 请求添加额外的 header,您可以将 Git 与 IIS 基本身份验证一起使用:

You could open IIS Manager -> IIS -> Authentication and check if the Basic Authentication is disabled.您可以打开IIS Manager -> IIS -> Authentication并检查 Basic Authentication 是否被禁用。

在此处输入图像描述

On the other hand, you could remove the Azure DevOps Server related credentials from Credential Manager: Open the control panel on windows–> Click on User Accounts–> Click on Manage your Credentials–>Click on Windows Credentials , locate the entry for your remote git repository–>Click on the item in the list and select Remove–> Finally try to use PAT again to clone a git Repo.另一方面,您可以从凭据管理器中删除 Azure DevOps Server 相关凭据:打开 Windows 上的control panel on windows–> Click on User Accounts–> Click on Manage your Credentials–>Click on Windows Credentials ,找到您的远程条目git repository-->点击列表中的项目和select Remove-->最后再次尝试使用PAT克隆一个git Repo。

暂无
暂无

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

相关问题 如何使用带有命令行 git 或 sourcetree 的 PAT 克隆 azure 开发操作 git 存储库? - how to clone an azure dev ops git repo using PAT with command line git or sourcetree? 无法使用 PAT 从 Azure DevOps 克隆 git - Cannot clone git from Azure DevOps using PAT DevOps 支持使用 PAT/GitCredManager/notSSH 远程 git 归档 | 在没有 git clone 的情况下下载 git repo 中的子文件夹 - DevOps support for git archive remote with PAT/GitCredManager/notSSH | download sub-folder within git repo without git clone Azure DevOps - 获取访问 git 存储库的用户的详细信息,包括克隆 - Azure DevOps -Get details of users accessing the git repo including clone 在 Azure 中,如何克隆在不同服务器中使用 git-lfs 存储库的存储库? - In Azure, how to clone a repo that uses git-lfs repo in a different server? 如何使用 PowerShell 任务 (git clone) 在 Azure DevOps Server 发布管道中运行 Git 命令 - How to run Git commands in Azure DevOps Server release pipeline using PowerShell tasks (git clone) 如何自动git自动克隆服务器上的repo? - How to automate git to automatically clone a repo on the server? 如何将 repo 克隆/复制到另一个 Azure DevOps 项目中? - How to clone/copy repo into another Azure DevOps project? Azure DevOps:如何使用 REST ZDB974238714CA8ADE4FZA repo 在 GIT 存储库中创建文件夹 - Azure DevOps: How to create a folder in GIT repo with REST API repo 您可以使用 Azure Devops Server 存储库中的 ssh 进行 git clone 吗? - Can you git clone with ssh from Azure Devops Server repos?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM