I've been trying to decrease the size of my Git repository by moving some files to git LFS. A few 100 commands further, here we are with files in git LFS and no more history of these files in my git commits.
However, whenever I clone the repository I am still downloading about 3gb of objects. I worked around this issue by creating a new repository in Visual Studio Team Services and after pruning and garbage collecting my repository locally, then doing a push to there, it was reduced to 300mb. (Command to do this locally found in this post: Git: what is a dangling commit/blob and where do they come from?)
However I can't imagine that you always have to delete / recreate a complete repository to remove dangling commits.
What I also tried was doing a git init, and then pushing that over the existing repository, but it only increased the object count further.
For anyone also running into similar issues, these were the command I executed to create a new repository without dangling commits, I would however like to find out how to do this in the existing repository without having to delete it:
git clone https://avavedse.visualstudio.com/Test/_git/TestRepository
cd blahblah
git reflog expire --expire=now --all
git gc --prune=now
git remote add newrepo https://avavedse.visualstudio.com/Test/_git/TestRepositoryNewEdition
git push newrepo