I have a requirement that I need to clean up GitLab repo, and need to remove all empty subdirectories present in a specific directory inside a specific project of a specific group.
Since, there are more than 10000 such directories that I need to remove, I was planning to do it programmatically using Gitlab python API.
However, I can't seem to find any way to list subdirectories or to remove them in GitLab Python API documentation. Is it possible to implement?
So, git
doesn't actually store directories themselves as objects that it manages. It stores paths in tree
objects, but once that part of the tree is empty they don't remove the sub-paths.
The simplest way to do the cleanup you want is simply remove all the files from the sub-directories and then reclone the repository. It will not recreate the sub-folders that are empty.
[Newer versions of git
may actually clean up sub-directories by the way, but older ones won't. My git
2.31 will, eg]