如何在 TFS 2015 中删除 Git 存储库? [英] How to remove Git repository in TFS 2015?

查看:28
本文介绍了如何在 TFS 2015 中删除 Git 存储库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试删除 TFS 2015 Update 1 中的 Git 存储库.该存储库是使用新的

解决方案

当一个项目中有多个 git repos 时其实很简单:

  1. 选择代码标签.
  2. 点击显示您的存储库的下拉菜单.
  3. 选择管理仓库.
  4. 点击您要删除的存储库旁边的上下文下拉菜单.
  5. 选择删除存储库.

编辑(基于您的编辑):

TFS 2015(更新 1)确实为 TFS 团队项目中包含的 Git 存储库数量设置了明确的最小限制.

TFS REST api 包含的函数可一起用于删除 git 存储库,但不会删除 TFS 项目中的 'last' 存储库.

这里是通用 API 文档

删除 git repo 涉及的两个函数是:

  1. 获取仓库列表

    (GET VERB) https://{instance}/defaultcollection/[{project}]/_apis/git/repositories?api-version={version}

当给定项目名称时,将返回包含 git 存储库及其存储库 ID 列表的 json.

  1. 删除存储库,当给定存储库 ID 时,将删除指定的存储库.

    (删除动词)https://{instance}/defaultcollection/_apis/git/repositories/{repository}?api-version={version}

不幸的是,在调用 delete repo 函数时有一个问题:

{"$id": "1"内部异常":空"message": "每个团队项目必须始终至少有一个存储库.""typeName": "Microsoft.TeamFoundation.Git.Server.GitRepositoryMinimumPerProjectThresholdExceededException, Microsoft.TeamFoundation.Git.Server, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a""typeKey": "GitRepositoryMinimumPerProjectThresholdExceededException"错误代码":0事件ID":3000}

异常MSDN 上的文档

在我拥有的实验室实例上查看 SQL Server(在我看来,如果在生产环境中误用​​,则不受支持)

TFS 数据库包含一个存储过程,它删除名为 prc_DeleteGitRepositories 的 git 存储库,它需要 4 个参数,我在数据库中或在 web-ui 上按 F12 找到这些参数.

调用如下:

EXEC prc_DeleteGitRepositories @partitionId=1,@teamProjectUri ='vstfs:///Classification/TestProject1/cbcc3093-247d-448a-8c3b-f5d447fc8afa',@repositoryId='4111286D-D066-4F3D-89B9-960055D678FE',@deleterId='769254d3-1f13-431c-a580-1500dcbffbce'

然而,在指定项目中仅存在 1 个 git repo 的情况下会抛出以下内容:

Msg 50000,级别 16,状态 1,过程 prc_DeleteGitRepositories,第 65 行%error="1200013";%:.TestCollection.dbo.prc_DeleteGitRepositories:每个团队项目必须始终至少有一个存储库.

总结一下:最适合用户声音,如我们对此 Q/A 的评论中所述.

I'm trying to remove a Git respository in TFS 2015 Update 1. The repository is created inside an existing TFVC team project using the new Git and TFVC in the same project feature. However I can create Git repositories using the TFS portal easily (using the Code tab), I can not find any feature inside the TFS portal or command line based feature to remove a Git repository. Also when I navigate through 'Manage repositories...' I can not find a feature called 'Remove repository'.

I had no luck Googling and searching the MSDN pages on this.

So I do not want to remove the entire team project (because it contains a lot of source code, work items and history), but only an empty Git repository.

Does anyone have a suggestion?

Edit #1 The sub menu that should display the 'Delete repository' option in the administrative pages, does not seem to be enabled when only one Git repository remains in a specific team project (see screenshot). For the record: it is visible when two or more Git repositories are present.

解决方案

Quite simple actually when there are multiple git repos in a project:

  1. Select the code tab.
  2. Click on the dropdown where it shows your repos.
  3. Select manage repositories.
  4. Click on the context dropdown next to the repo you want to delete.
  5. Select delete repository.

Edit (based on your edit):

TFS 2015 (update 1) indeed has an explicit minimum limit set for the number of Git repos contained within a TFS team project.

The TFS REST api contains functions which together can be used to delete a git repo but it does not delete the 'last' repo in the TFS project.

Here is the general API documentation

Two functions involved with deleting a git repo are:

  1. Get a list of repositories

    (GET VERB) https://{instance}/defaultcollection/[{project}]/_apis/git/repositories?api-version={version}

Which when given a project name returns json containing a list of git repos and their repo ID's.

  1. Delete a repository which when given a repo ID will delete the specified repo.

    (DELETE VERB) https://{instance}/defaultcollection/_apis/git/repositories/{repository}?api-version={version}

Unfortunately there is a catch when invoking the delete repo function:

{
"$id": "1"
"innerException": null
"message": "There must always be at least one repository per Team Project."
"typeName": "Microsoft.TeamFoundation.Git.Server.GitRepositoryMinimumPerProjectThresholdExceededException, Microsoft.TeamFoundation.Git.Server, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
"typeKey": "GitRepositoryMinimumPerProjectThresholdExceededException"
"errorCode": 0
"eventId": 3000
}

Exception documentation on MSDN

Looking at SQL server on a lab instance I have (in my opinion unsupported if misused in a prod environment)

The TFS database contains a stored procedure which deletes git repos called prc_DeleteGitRepositories, it takes 4 arguments which I hunted down either in the database or hitting F12 on the web-ui.

It is invoked as follows:

EXEC prc_DeleteGitRepositories @partitionId=1, 
@teamProjectUri ='vstfs:///Classification/TestProject1/cbcc3093-247d-448a-8c3b-f5d447fc8afa', 
@repositoryId='4111286D-D066-4F3D-89B9-960055D678FE', 
@deleterId='769254d3-1f13-431c-a580-1500dcbffbce'

That however throws the following in the scenario where only 1 git repo exists in the specified project:

Msg 50000, Level 16, State 1, Procedure prc_DeleteGitRepositories, Line 65
%error="1200013";%:<SERVERNAME>.TestCollection.dbo.prc_DeleteGitRepositories: There must always be at least one repository per Team Project.

So to summarize: a potential feature request best suited to uservoice as discussed in our comments on this Q/A.

这篇关于如何在 TFS 2015 中删除 Git 存储库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆