Pushing empty commits or in general with no files changed is mostly done when triggering a deployment (CI/CD) pipeline, speaking from my personal experience for sure. However, if you want to get rid of them, you need to know how to list them first. Here’s some useful commands to do so.
To list empty commits only, go to your current Git repo and run the following command:
git rev-list HEAD | while read commitHash; do if [ $(git diff-tree --name-status --no-commit-id $commitHash | wc -l) -eq 0 ]; then echo $commitHash fi; done
To list non-empty commits only, run:
git rev-list HEAD | while read commitHash; do git diff-tree --name-status $commitHash done