首页 > git > 使用GIT-TFS工具将Azure DevOps TFVC集合中的所有历史记录克隆到Git时出现TF31002错误

使用GIT-TFS工具将Azure DevOps TFVC集合中的所有历史记录克隆到Git时出现TF31002错误 (TF31002 error when cloning all history from Azure DevOps TFVC collection to Git with GIT-TFS tool)

问题

我正在尝试将项目从Azure DevOps TFVC迁移到Azure DevOps Git,其中包含所有变更集历史记录,不仅仅是过去180天。为了以防万一,我使用Azure DevOps中包含的工具迁移了过去180天的更改。所以现在我在这个项目中有2个存储库:

  • 带有{collection-name}的TFVC集合
  • 使用其他名称的Git存储库。

我问这里,我被困在“将存储库克隆到本地文件夹”步骤。我安装了Git并下载了最新的GIT-TFS工具。

我在Azure DevOps上有个人和专业帐户{email-account}。我要迁移的项目位于个人帐户中。我在这个官方帮助后运行此命令:

git tfs clone -u {email-account} -p {personal-account-password} https://{devops-username}.visualstudio.com/{collection-name}/ $/{folder-name}/ . --branches=none

我得到的{collection-name}{folder-name}从Visual Studio 2017年专业版,当我试图连接到远程采集。我只有这个版本的VS. 运行命令后,我得到这个输出:

Initialized empty Git repository in C:/DATA/Git/.git/

TF31002: Unable to connect to this Team Foundation Server: https://{devops-username}.visualstudio.com/{collection-name}.
Team Foundation Server Url: https://{devops-username}.visualstudio.com/{collection-name}.

Possible reasons for failure include:
- The name, port number, or protocol for the Team Foundation Server is incorrect.
- The Team Foundation Server is offline.
- The password has expired or is incorrect.

Technical information (for administrator):
The remote server returned an error: (404) Not Found.
The remote server returned an error: (404) Not Found.
All the logs could be found in the log file: C:\Users\{user}\AppData\Local\git-tfs\git-tfs_log.txt

如果有帮助,这里是日志文件内容:

2019-03-04 11:42:17.4562 [Debug] Trying to get HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\DevDiv\vs\Servicing\14.0
2019-03-04 11:42:17.4816 [Debug] Visual Studio 2015 detected...
2019-03-04 11:42:17.6387 [Debug] git command: Starting process: git rev-parse --show-prefix
2019-03-04 11:42:17.6744 [Debug] git stderr: fatal: not a git repository (or any of the parent directories): .git
2019-03-04 11:42:17.6744 [Debug] git command time: [00:00:00.0396901] rev-parse --show-prefix
2019-03-04 11:42:17.7083 [Debug] Command run:git tfs clone -u {email-account} -p {personal-account-password} https://{devops-username}.visualstudio.com/{collection-name} $/{folder-name} . --branches=none
2019-03-04 11:42:17.7083 [Debug] No authors file used.
2019-03-04 11:42:17.7083 [Debug] git-tfs version 0.29.0.0 (TFS client library 14.0.0.0 (MS)) (64-bit)
2019-03-04 11:42:17.7379 [Debug] Looking for assembly StructureMap.resources, Version=2.6.1.0, Culture=en-US, PublicKeyToken=e60ad81abae3c223 ...
2019-03-04 11:42:17.7379 [Debug] Trying to get HKEY_LOCAL_MACHINE\Software\WOW6432Node\Microsoft\VisualStudio\14.0|InstallDir
2019-03-04 11:42:17.7379 [Debug] Trying to get HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\14.0|InstallDir
2019-03-04 11:42:17.7379 [Debug] Trying to get HKEY_CURRENT_USER\Software\WOW6432Node\Microsoft\WDExpress\14.0_Config|InstallDir
2019-03-04 11:42:17.7379 [Debug] Trying to get HKEY_CURRENT_USER\Software\Microsoft\WDExpress\14.0_Config|InstallDir
2019-03-04 11:42:17.7379 [Debug] Looking for assembly StructureMap.resources, Version=2.6.1.0, Culture=en, PublicKeyToken=e60ad81abae3c223 ...
2019-03-04 11:42:17.7379 [Debug] Trying to get HKEY_LOCAL_MACHINE\Software\WOW6432Node\Microsoft\VisualStudio\14.0|InstallDir
2019-03-04 11:42:17.7379 [Debug] Trying to get HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\14.0|InstallDir
2019-03-04 11:42:17.7379 [Debug] Trying to get HKEY_CURRENT_USER\Software\WOW6432Node\Microsoft\WDExpress\14.0_Config|InstallDir
2019-03-04 11:42:17.7379 [Debug] Trying to get HKEY_CURRENT_USER\Software\Microsoft\WDExpress\14.0_Config|InstallDir
2019-03-04 11:42:17.7379 [Debug] git command: Starting process: git init
2019-03-04 11:42:17.8112 [Info] Initialized empty Git repository in C:/DATA/Git/.git/

2019-03-04 11:42:17.8252 [Debug] git command time: [00:00:00.0767692] init
2019-03-04 11:42:17.8481 [Debug] No .gitignore file specified...
2019-03-04 11:42:18.9405 [Debug] System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> Microsoft.TeamFoundation.TeamFoundationServiceUnavailableException: TF31002: Unable to connect to this Team Foundation Server: https://{devops-username}.visualstudio.com/{collection-name}.
Team Foundation Server Url: https://{devops-username}.visualstudio.com/{collection-name}.

Possible reasons for failure include:
- The name, port number, or protocol for the Team Foundation Server is incorrect.
- The Team Foundation Server is offline.
- The password has expired or is incorrect.

Technical information (for administrator):
The remote server returned an error: (404) Not Found. ---> System.Net.WebException: The remote server returned an error: (404) Not Found.
   at System.Net.HttpWebRequest.GetResponse()
   at Microsoft.TeamFoundation.Client.Channels.TfsHttpWebRequest.SendRequestAndGetResponse(HttpWebRequest webRequest, WebException& webException)
   --- End of inner exception stack trace ---
   at Microsoft.TeamFoundation.Client.TfsConnection.EnsureProviderConnected()
   at Microsoft.TeamFoundation.Client.TfsConnection.EnsureAuthenticated()
   at GitTfs.VsCommon.TfsHelperBase.EnsureAuthenticated()
   at GitTfs.Core.GitTfsRemote.EnsureTfsAuthenticated()
   at GitTfs.Core.GitRepository.CreateTfsRemote(RemoteInfo remote, String autocrlf, String ignorecase)
   at GitTfs.Commands.Init.Run(String tfsUrl, String tfsRepositoryPath)
   at GitTfs.Commands.Init.Run(String tfsUrl, String tfsRepositoryPath, String gitRepositoryPath)
   at GitTfs.Commands.Clone.Run(String tfsUrl, String tfsRepositoryPath, String gitRepositoryPath)
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at GitTfs.Util.GitTfsCommandRunner.Run(GitTfsCommand command, IList`1 args)
   at GitTfs.GitTfs.Main(GitTfsCommand command, IList`1 unparsedArgs)
   at GitTfs.GitTfs.Run(IList`1 args)
   at GitTfs.Program.Main(String[] args)
2019-03-04 11:42:18.9635 [Error] TF31002: Unable to connect to this Team Foundation Server: https://{devops-username}.visualstudio.com/{collection-name}.
Team Foundation Server Url: https://{devops-username}.visualstudio.com/{collection-name}.

Possible reasons for failure include:
- The name, port number, or protocol for the Team Foundation Server is incorrect.
- The Team Foundation Server is offline.
- The password has expired or is incorrect.

Technical information (for administrator):
The remote server returned an error: (404) Not Found.
2019-03-04 11:42:18.9635 [Error] The remote server returned an error: (404) Not Found.
2019-03-04 11:42:18.9734 [Warn] All the logs could be found in the log file: C:\Users\{user}\AppData\Local\git-tfs\git-tfs_log.txt

解决方法

要在Azure DevOps上克隆TFVC存储库,您应该:

  • 启用备用凭据。转到“我的个人资料” - >“安全” - >输入数据和“启用备用凭据”
  • 使用此模式后面的命令(在上一步中定义'yourLogin'和'yourPassword') git tfs clone https://dev.azure.com/{organization} $/project/folder --username=yourLogin --password=yourPassword

在此输入图像描述

为了成功,visualstudio.com需要(用于身份验证)您使用TFS2012版本的TFS dll。否则,您将看到以下消息:

TF400813: Resource not available for anonymous access. Client authentication required

为了确保git-tfs使用此版本,请使用该命令git tfs --version,您应该看到文本TFS client library 11.0.0.0,如:

git-tfs version 0.17.2.0 (TFS client library 11.0.0.0 (MS)) (64-bit)

问题

I am trying to migrate a project from Azure DevOps TFVC to Azure DevOps Git with all changeset history, not only for the last 180 days. Just in case, I have migrated the changes of the last 180 days with the tool included in Azure DevOps. So now I have 2 repositories en this project:

  • TFVC collection with {collection-name}
  • Git repository with another name.

I asked here and I am stuck in "Clone the repository to a local folder" step. I have Git installed and downloaded the latest realease of GIT-TFS tool.

I have a Personal and Professional account on Azure DevOps with {email-account}. The project I want to migrate is in the Personal account. I am running this command following this official help:

git tfs clone -u {email-account} -p {personal-account-password} https://{devops-username}.visualstudio.com/{collection-name}/ $/{folder-name}/ . --branches=none

I get {collection-name} and {folder-name} from Visual Studio 2017 Pro when I tried to connect to the remote collection. I have only this version of VS. After running the command I get this output:

Initialized empty Git repository in C:/DATA/Git/.git/

TF31002: Unable to connect to this Team Foundation Server: https://{devops-username}.visualstudio.com/{collection-name}.
Team Foundation Server Url: https://{devops-username}.visualstudio.com/{collection-name}.

Possible reasons for failure include:
- The name, port number, or protocol for the Team Foundation Server is incorrect.
- The Team Foundation Server is offline.
- The password has expired or is incorrect.

Technical information (for administrator):
The remote server returned an error: (404) Not Found.
The remote server returned an error: (404) Not Found.
All the logs could be found in the log file: C:\Users\{user}\AppData\Local\git-tfs\git-tfs_log.txt

And if it helps, here is log file content:

2019-03-04 11:42:17.4562 [Debug] Trying to get HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\DevDiv\vs\Servicing\14.0
2019-03-04 11:42:17.4816 [Debug] Visual Studio 2015 detected...
2019-03-04 11:42:17.6387 [Debug] git command: Starting process: git rev-parse --show-prefix
2019-03-04 11:42:17.6744 [Debug] git stderr: fatal: not a git repository (or any of the parent directories): .git
2019-03-04 11:42:17.6744 [Debug] git command time: [00:00:00.0396901] rev-parse --show-prefix
2019-03-04 11:42:17.7083 [Debug] Command run:git tfs clone -u {email-account} -p {personal-account-password} https://{devops-username}.visualstudio.com/{collection-name} $/{folder-name} . --branches=none
2019-03-04 11:42:17.7083 [Debug] No authors file used.
2019-03-04 11:42:17.7083 [Debug] git-tfs version 0.29.0.0 (TFS client library 14.0.0.0 (MS)) (64-bit)
2019-03-04 11:42:17.7379 [Debug] Looking for assembly StructureMap.resources, Version=2.6.1.0, Culture=en-US, PublicKeyToken=e60ad81abae3c223 ...
2019-03-04 11:42:17.7379 [Debug] Trying to get HKEY_LOCAL_MACHINE\Software\WOW6432Node\Microsoft\VisualStudio\14.0|InstallDir
2019-03-04 11:42:17.7379 [Debug] Trying to get HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\14.0|InstallDir
2019-03-04 11:42:17.7379 [Debug] Trying to get HKEY_CURRENT_USER\Software\WOW6432Node\Microsoft\WDExpress\14.0_Config|InstallDir
2019-03-04 11:42:17.7379 [Debug] Trying to get HKEY_CURRENT_USER\Software\Microsoft\WDExpress\14.0_Config|InstallDir
2019-03-04 11:42:17.7379 [Debug] Looking for assembly StructureMap.resources, Version=2.6.1.0, Culture=en, PublicKeyToken=e60ad81abae3c223 ...
2019-03-04 11:42:17.7379 [Debug] Trying to get HKEY_LOCAL_MACHINE\Software\WOW6432Node\Microsoft\VisualStudio\14.0|InstallDir
2019-03-04 11:42:17.7379 [Debug] Trying to get HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\14.0|InstallDir
2019-03-04 11:42:17.7379 [Debug] Trying to get HKEY_CURRENT_USER\Software\WOW6432Node\Microsoft\WDExpress\14.0_Config|InstallDir
2019-03-04 11:42:17.7379 [Debug] Trying to get HKEY_CURRENT_USER\Software\Microsoft\WDExpress\14.0_Config|InstallDir
2019-03-04 11:42:17.7379 [Debug] git command: Starting process: git init
2019-03-04 11:42:17.8112 [Info] Initialized empty Git repository in C:/DATA/Git/.git/

2019-03-04 11:42:17.8252 [Debug] git command time: [00:00:00.0767692] init
2019-03-04 11:42:17.8481 [Debug] No .gitignore file specified...
2019-03-04 11:42:18.9405 [Debug] System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> Microsoft.TeamFoundation.TeamFoundationServiceUnavailableException: TF31002: Unable to connect to this Team Foundation Server: https://{devops-username}.visualstudio.com/{collection-name}.
Team Foundation Server Url: https://{devops-username}.visualstudio.com/{collection-name}.

Possible reasons for failure include:
- The name, port number, or protocol for the Team Foundation Server is incorrect.
- The Team Foundation Server is offline.
- The password has expired or is incorrect.

Technical information (for administrator):
The remote server returned an error: (404) Not Found. ---> System.Net.WebException: The remote server returned an error: (404) Not Found.
   at System.Net.HttpWebRequest.GetResponse()
   at Microsoft.TeamFoundation.Client.Channels.TfsHttpWebRequest.SendRequestAndGetResponse(HttpWebRequest webRequest, WebException& webException)
   --- End of inner exception stack trace ---
   at Microsoft.TeamFoundation.Client.TfsConnection.EnsureProviderConnected()
   at Microsoft.TeamFoundation.Client.TfsConnection.EnsureAuthenticated()
   at GitTfs.VsCommon.TfsHelperBase.EnsureAuthenticated()
   at GitTfs.Core.GitTfsRemote.EnsureTfsAuthenticated()
   at GitTfs.Core.GitRepository.CreateTfsRemote(RemoteInfo remote, String autocrlf, String ignorecase)
   at GitTfs.Commands.Init.Run(String tfsUrl, String tfsRepositoryPath)
   at GitTfs.Commands.Init.Run(String tfsUrl, String tfsRepositoryPath, String gitRepositoryPath)
   at GitTfs.Commands.Clone.Run(String tfsUrl, String tfsRepositoryPath, String gitRepositoryPath)
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at GitTfs.Util.GitTfsCommandRunner.Run(GitTfsCommand command, IList`1 args)
   at GitTfs.GitTfs.Main(GitTfsCommand command, IList`1 unparsedArgs)
   at GitTfs.GitTfs.Run(IList`1 args)
   at GitTfs.Program.Main(String[] args)
2019-03-04 11:42:18.9635 [Error] TF31002: Unable to connect to this Team Foundation Server: https://{devops-username}.visualstudio.com/{collection-name}.
Team Foundation Server Url: https://{devops-username}.visualstudio.com/{collection-name}.

Possible reasons for failure include:
- The name, port number, or protocol for the Team Foundation Server is incorrect.
- The Team Foundation Server is offline.
- The password has expired or is incorrect.

Technical information (for administrator):
The remote server returned an error: (404) Not Found.
2019-03-04 11:42:18.9635 [Error] The remote server returned an error: (404) Not Found.
2019-03-04 11:42:18.9734 [Warn] All the logs could be found in the log file: C:\Users\{user}\AppData\Local\git-tfs\git-tfs_log.txt

解决方法

To clone a TFVC repository on Azure DevOps, you should:

  • Enable alternate credentials. Go to "My profile"->"Security"-> Enter data and "Enable alternate credentials"
  • use the command following this pattern (where 'yourLogin' and 'yourPassword' was defined in the previous step) git tfs clone https://dev.azure.com/{organization} $/project/folder --username=yourLogin --password=yourPassword

enter image description here

To succeed, visualstudio.com needs (for authentication) that you use the TFS2012 version of the TFS dlls. Otherwise, you will see the message :

TF400813: Resource not available for anonymous access. Client authentication required

To be sure that git-tfs uses this version, use the command git tfs --version and you should see the text TFS client library 11.0.0.0, like in:

git-tfs version 0.17.2.0 (TFS client library 11.0.0.0 (MS)) (64-bit)

相似信息