I just migrated a project from Mercurial to Git. Mercurial adds empty commits when you add tags, so I ended up with empty commits in Git that I would like to remove.
Using --commit-filter should be faster than using --prune-empty
$ git filter-branch --tag-name-filter cat --commit-filter 'git_commit_non_empty_tree "$@"' -- --all
Then clean the backup refs as in torek's answer
$ git for-each-ref --format="%(refname)" refs/original/ | xargs -n 1 git update-ref -d
Taken from here: Git - remove commits with empty changeset using filter-branch