Search code examples
filerepositorybitbucketbare

DELETED file in git bare repository


I noticed that on Bitbucket server side in "repository" catalog in some of repositories is "DELETED" file exist. It is means that repo was deleted?)


Solution

  • I noticed these DELETED files in our Bitbucket server filesystem too, so my team reached out to our contact at Bitbucket. Turns out that if you delete a repository that has been forked, removing it from the filesystem would break the forks because they wouldn't be able to reference the original commits. So instead, Bitbucket deletes the repo from the database but leaves it on the filesystem, adding this "DELETED" file to indicate that the repo has been deleted from the Bitbucket database.

    Unfortunately, even if you delete all of the forks after that, Bitbucket has lost the reference to the original repo so it doesn't know to go back and clean the repo up. If you want to delete these unused repos, you would want to check the filesystem for any references to the deleted repo.

    Our Bitbucket contact said this should do the trick:

    $ cd /apps/stash-home/shared/data/repositories
    $ find -name alternates -exec grep -iRl "repositories/12345" {} \;
    

    where 12345 is the repository_id for the deleted repo.

    If there are no references to repo 12345, you're safe to delete it. If there are, you should check whether those forks are in use anymore and clean them up if not.