简体   繁体   English

为什么我不能将我的 Azure DevOps 存储库导入到新的 Azure DevOps 存储库?

[英]Why can't I import my Azure DevOps repo to a new Azure DevOps repo?

I'm trying to create a new repository in Azure DevOps based on an old repository also in Azure DevOps, but the transfer is not working.我正在尝试基于 Azure DevOps 中的旧存储库在 Azure DevOps 中创建新存储库,但传输不起作用。

The new repository is under a new project and organization.新存储库位于新项目和组织下。 When I create it and go to Repos, I see this:当我创建它并转到 Repos 时,我看到:

在此处输入图片说明

It seems like I have two options for importing the old repository over to this one:似乎我有两个选项可以将旧存储库导入到这个:

  • Push an existing repository from command line.从命令行推送现有存储库。
  • Import a repository.导入存储库。

When I try to push an existing repository from the command line, I copy and paste the commands it gives me to the command line (PowerShell) while in the root of the project directory on my local computer (where the .git folder and .sln file are).当我尝试从命令行推送现有存储库时,我将它提供给我的命令复制并粘贴到命令行 (PowerShell) 中,同时位于本地计算机上项目目录的根目录中(其中 .git 文件夹和 .sln文件是)。 The command is:命令是:

git remote add origin https://holland-and-barnes@dev.azure.com/holland-and-barnes/Holland%20and%20Barnes/_git/Holland%20and%20Barnes

Running this command, it tells me:运行这个命令,它告诉我:

usage: git remote add [<options>] <name> <url>

    -f, --fetch           fetch the remote branches
    --tags                import all tags and associated objects when fetching
                          or do not fetch any tag at all (--no-tags)
    -t, --track <branch>  branch(es) to track
    -m, --master <branch>
                          master branch
    --mirror[=(push|fetch)]
                          set up remote as a mirror to push to or fetch from

...and then: ...进而:

git push -u origin --all

Running this command, it tells me:运行这个命令,它告诉我:

Everything up-to-date
Branch 'master' set up to track remote branch 'master' from 'origin'.

And yet, back at dev.azure.com, it still says "Holland and Barnes is empty. Add some code!"然而,回到 dev.azure.com,它仍然说“Holland and Barnes 是空的。添加一些代码!”

So I try the second method (importing from the old repository).所以我尝试第二种方法(从旧存储库导入)。

I click "Import" and it brings up the "Import a Git repository" popup:我单击“导入”,它会弹出“导入 Git 存储库”弹出窗口:

在此处输入图片说明

I keep the repository type as Git and I enter the following for the Clone URL:我将存储库类型保留为 Git,并为克隆 URL 输入以下内容:

https://wardrop.visualstudio.com/Holland%20And%20Barnes/_git/Holland%20And%20Barnes

I get this directly from the Clone Repository popup of the old repository (Repos >> click on Clone):我直接从旧存储库的克隆存储库弹出窗口中获取此信息(存储库 >> 单击克隆):

在此处输入图片说明

I check "Requires Authentication" and enter my username and Password.我选中“需要身份验证”并输入我的用户名和密码。 I click "Import".我点击“导入”。

But it tells me in pink at the top:但它在顶部用粉红色告诉我:

Import request cannot be processed due to one of the following reasons:

Clone URL is incorrect.
Clone URL requires authorization

在此处输入图片说明

I am sure I'm entering my credentials properly.我确信我正确输入了我的凭据。 I copied the clone URL directly from the old repository.我直接从旧存储库复制了克隆 URL。 What else can I do?我还可以做些什么?

What else can I do?我还可以做些什么?

The easiest way to import repo is to use import option in Azure Devops(Same as your method 2).导入 repo 的最简单方法是使用 Azure Devops 中的导入选项(与方法 2 相同)。

But from your screenshot, it seems that you are using the UserName and Password .但是从您的屏幕截图来看,您似乎正在使用UserName and Password

If yes, you could try to use PAT ( Use personal access tokens ).如果是,您可以尝试使用 PAT( 使用个人访问令牌)。

You could grant the Full Access to the PAT and check if it could work.您可以授予对 PAT 的完全访问权限并检查它是否可以工作。

On my side, if I use UserName+ Password , I get the same error message.在我这边,如果我使用UserName+ Password ,我会收到相同的错误消息。 But UserName+PAT can work fine但是UserName+PAT可以正常工作

Another way is Git command.另一种方法是 Git 命令。

You could try the following Scripts:您可以尝试以下脚本:

git clone https://xxx.visualstudio.com/Holland%20And%20Barnes/_git/Holland%20And%20Barnes

cd xxxx/xx/Holland%20And%20Barnes

git remote add origin https://xxx@dev.azure.com/xxx/xxx/_git/xxx

git push -u origin --all

Result:结果:

在此处输入图片说明

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

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