Hi Noah Wolton
The LFS objects are not always cleaned up automatically after repo deletion especially in on-premises Azure DevOps Server environments.
Could you please follow the below steps:
- On your collection database, run the following (with caution and backups in place):
These are safe to run and are designed to clean up orphaned file content. You may need to run the second one multiple times depending on the batch size.EXEC prc_CleanupDeletedFileContent 1; EXEC prc_DeleteUnusedFiles 1, 0, 100000; - Run a query like:
If the reference count is 0, those objects are orphaned and eligible for deletion.SELECT o.LfsObjectId, COUNT(r.RepositoryId) AS ReferenceCount FROM GitOdb.tbl_LfsObject AS o LEFT JOIN Git.tbl_LfsObjectToRepository AS r ON o.LfsObjectId = r.LfsObjectId GROUP BY o.LfsObjectId HAVING COUNT(r.RepositoryId) = 0 - Even if the SQL DB has cleaned up rows, physical disk usage might remain, So, Check
C:\Program Files\Azure DevOps Server\or the location of yourGitRepositoriesandLfsObjectsdirectories. - Azure DevOps has scheduled jobs that handle cleanup tasks, including the removal of orphaned LFS objects. However, these jobs may not run immediately or may have specific conditions for execution - https://docs.github.com/en/repositories/working-with-files/managing-large-files/removing-files-from-git-large-file-storage You can use the following command to remove LFS objects:
git lfs prune
Hope this helps!
Please Let me know if you have any queries.