如何直接从 git bash 命令行创建 azure 存储库?(无需进入浏览器)

Alv*_*nez 6 git repository azure azure-cli azure-devops

更新

我正在尝试从 git bash 命令行创建一个存储库到 AzureDevops 团队平台,

我一直遵循这些说明:

https://learn.microsoft.com/en-us/azure/devops/repos/git/share-your-code-in-git-cmdline?view=azure-devops

我在先决条件方面遇到问题,我运行了下一行:

az --version                          # version is greater than v2.0.49
az extension add --name azure-devops  # no problem with this line 
az devops login --organization org_url 
PAT                                   # problem arises here.... 
Run Code Online (Sandbox Code Playgroud)

运行结束行后出现下一行:

Failed to authenticate using the supplied token.

我按照以下说明创建 PAT:

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

我是否必须要求提供经理凭据,否则我可以采取什么措施来解决此问题?

Nan*_*ong 2

从错误消息来看,您可能需要安装 Azure CLI。您必须至少有v2.0.49,您可以使用命令验证az --version。然后你可以运行az login命令使用您的Azure帐户登录。

更新

跟着文章走就行了。您可以在 git bash 或其他终端中执行以下步骤:

  1. 下载并安装 Azure CLI 并添加 Azure DevOps 扩展。
   az extension add --name azure-devops
   az login #login in with your Azure account
   az devops configure --defaults organization=https://dev.azure.com/contoso project=contoso
Run Code Online (Sandbox Code Playgroud)
  1. 为您的代码创建本地 Git 存储库。如果您的代码已位于本地 Git 存储库中,则可以跳过此步骤。
cd /home/fabrikam/fiber
git init .
git add --all
git commit -m "first commit of my code"
Run Code Online (Sandbox Code Playgroud)
  1. remoteUrl在 Azure Repos 中创建一个新的 Git 存储库,并使用创建的 Git 存储库的响应将本地存储库连接到 Azure Repos 中的 Git 存储库:
az repos create --name  mywebapprepos
git remote add origin https://xxx.xxx.com/webapp-test/_git/mywebapprepos
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

  1. 在推送代码之前,您需要使用 Azure 帐户登录进行身份验证。对于我来说,它将提示 Windows UI 使用我的帐户登录。
git push origin master
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述