How to list/delete all empty repositories in GitLab. I have multiple empty repros in my GitLab. Is there any way to delete them all instead of deleting them manually?
I am not providing you the script here, as i have not written one, i just outline the process i would choose and the APIs which would be useful for this job.
The question first to ask is, how do you define an empty repository - lets assume you say a repository with a certain amount of commits.
For this you can use the projects API https://docs.gitlab.com/ee/api/projects.html#list-all-projects - where you can get a list of all projects, with some statistics and generate a list out of those who matches your characteristics. (statistics.commits
is a nice field for that)
GET /users/:user_id/projects
With this list of projects IDs you can start deleting them with the project API for deleting https://docs.gitlab.com/ee/api/projects.html#delete-project
DELETE /projects/:id