我使用 git-tfs 来处理 TFVC 存储库。我开始从事其他项目,该项目的代码托管在不同的服务器上。

现在,当我尝试克隆存储库时出现错误。

git tfs clone http://tfs-server:8080/tfs $/CompanyName/Dev

它提示我输入两次凭据。然后它显示一个错误。
TF30063: You are not authorized to access http://tfs-server:8080/tfs.
The remote server returned an error: (401) Unauthorized.

我已经仔细检查过它是一个正确的网址。我可以连接 Visual Studio 和浏览器。

我已经仔细检查过它是正确的密码和用户名。我可以在浏览器中使用此凭据登录。

我能够从我机器上的不同服务器克隆代码。

服务器是 Visual Studio Team Foundation Server 2013。我的 git-tfs 版本是
git-tfs version 0.21.0.0 (TFS client library 12.0.0.0 (MS)) (64-bit)

我发现了一些有类似错误的问题,并尝试了答案。所以这些是我尝试做的事情:
  • 在 Visual Studio 的浏览器中从此服务器注销;
  • 清理 Internet Explorer 缓存
  • 删除 C:\Users\UserName\AppData\Local\Microsoft\Team Foundation\5.0\Cache 文件夹;
  • 在 Internet Explorer 中将 tfs 服务器添加到本地内网安全区域。

  • 这是调试输出:
    git tfs clone http://tfs-server:8080/tfs $/CompanyName/Dev --debug
    
    Command run:git tfs clone http://tfs-server:8080/tfs $/CompanyName/Dev --debug
    No authors file used.
    git-tfs version 0.21.0.0 (TFS client library 12.0.0.0 (MS)) (64-bit)
    git command: Starting process: git init
    Initialized empty Git repository in C:/Users/UserName/Dev/.git/
    git command time: [00:00:00.0660000] init
    System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> Microsoft.TeamFoundation.TeamFoundationServerUnauthorizedException: TF30063: You are not authorized to access http://tfs-server:8080/tfs. ---> System.Net.WebException: The remote server returned an error: (401) Unauthorized.
       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.Channels.TfsHttpWebRequest.ReadResponse(HttpWebResponse webResponse, WebException webException)
       at Microsoft.TeamFoundation.Client.Channels.TfsHttpWebRequest.SendRequest()
       at Microsoft.TeamFoundation.Client.Channels.TfsHttpRequestChannel.Request(TfsMessage message, TimeSpan timeout)
       at Microsoft.TeamFoundation.Client.Channels.TfsHttpClientBase.Invoke(TfsClientOperation operation, Object[] parameters, TimeSpan timeout, Object[]& outputs)
       at Microsoft.TeamFoundation.Framework.Client.RegistrationProxy.GetRegistrationEntries(String toolId)
       at Microsoft.TeamFoundation.Framework.Client.RegistrationService.GetInstanceId()
       at Microsoft.TeamFoundation.Framework.Client.RegistrationService.get_InstanceClientCacheDirectory()
       at Microsoft.TeamFoundation.Framework.Client.RegistrationService..ctor(TfsTeamProjectCollection tfsObject)
       at Microsoft.TeamFoundation.Client.TfsTeamProjectCollection.CreateServiceProxy(Type serviceType)
       at Microsoft.TeamFoundation.Client.TfsConnection.GetService(Type serviceType)
       at Microsoft.TeamFoundation.Framework.Client.PreFrameworkServerDataProvider.FindServiceLocation(String serviceType, String toolId)
       at Microsoft.TeamFoundation.Framework.Client.PreFrameworkServerDataProvider.LocationForCurrentConnection(String serviceType, Guid serviceIdentifier)
       at Microsoft.TeamFoundation.Client.TfsConnection.EnsureProviderConnected()
       at Microsoft.TeamFoundation.Client.TfsConnection.EnsureAuthenticated()
       at Sep.Git.Tfs.VsCommon.TfsHelperBase.EnsureAuthenticated()
       at Sep.Git.Tfs.Core.GitTfsRemote.EnsureTfsAuthenticated()
       at Sep.Git.Tfs.Core.GitRepository.CreateTfsRemote(RemoteInfo remote, String autocrlf, String ignorecase)
       at Sep.Git.Tfs.Commands.Init.Run(String tfsUrl, String tfsRepositoryPath)
       at Sep.Git.Tfs.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 Sep.Git.Tfs.Util.GitTfsCommandRunner.Run(GitTfsCommand command, IList`1 args)
       at Sep.Git.Tfs.GitTfs.Main(GitTfsCommand command, IList`1 unparsedArgs)
       at Sep.Git.Tfs.Program.Main(String[] args)
    TF30063: You are not authorized to access http://tfs-server:8080/tfs.
    The remote server returned an error: (401) Unauthorized.
    

    我该怎么做才能让我的 git-tfs 流回来?

    最佳答案

    我已经将集合名称添加到服务器的 url 并且它起作用了。

    正确的命令是:

    git tfs clone http://tfs-server:8080/tfs/collectionName $/CompanyName/Dev
    

    尽管问题中的命令适用于以前的服务器。

    关于git-tfs 克隆存储库时返回 "(401) unauthorized"错误,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/29703510/

    10-15 04:07