4

I am trying to find the equivalent action of tf destroyfor a Git repository. That is to say, permanently delete the Git repository and recover the space in the database. Running TFS 2017 U3.

We have a number of Git repositories which where either added in error or are now obsolete and can be discarded. Merely "deleting" the repository does not appear to recover the space in the database. I am aware TFS cleanup runs on either a 5 or 7 day cycle to recover the space.

It appears TFS internally keeps track of the deleted repositories in a table - dbo.tbl_GitDeletedRepository, which also suggests they can be recovered (tho no option to do so).

Note: I am aware you cannot delete if only single repo is left.

In the alternative, is there a recommended approach to blow away the entire contents of the repository, compress the repository (gc?), push that to TFS and thus recover the space in the database?

Ian W
  • 4,559
  • 2
  • 18
  • 37
  • 1
    Did you ever figure out a solution to this? I'm encountering the exact same issue, waited the 7 days that should have pruned it, but still no pruning. I even have a completely deleted dataspace that hasn't been cleaned up. It does look like it eventually gets pruned (I have two that have been.) But I have some almost 2 weeks old and still hanging around. – AJ Henderson Jan 28 '19 at 17:07

1 Answers1

0

There are many different types of files stored in TFS collection databases, including Team Foundation Version Control files, Git files, work item attachments, test case attachments, build outputs, etc. Not all of them support cleanup. Also, note that file contents are not generally cleaned up immediately upon deletion, but rather by a background job that runs on a periodic basis (typically once per day).

For Git, you can try running below commands, then delete the repository. (Delete the entire Team Project if the projects are no longer needed)

git reflog expire --all --expire=now
git gc --prune=now --aggressive

Refer to this thread for details: Reduce git repository size

You can also reference below articles to clean up the GIT repository:

Andy Li-MSFT
  • 28,712
  • 2
  • 33
  • 55
  • 1
    I do not believe the advice applies. It's not about deleting contents from the repo, rather deleting the repo itself from TFS. From the UI, Version Control under Settings, choose a repo, right-click, Delete. Net result is it now ends up as an entry in DB [dbo].[tbl_GitDeletedRepository]. Entry also remains in [dbo].[tbl_Repository] with [State] = 4. That suggests: 1) it's not really gone (as tf destroy does for tfvc objects), 2) it is recoverable, though no documentation on how. – Ian W May 09 '18 at 07:41