How to list Git empty commits

Aug 26, 2022 · 1 min read · 3 views · Post a comment

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.


  • Git


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

To list non-empty commits only, run:

git rev-list HEAD | while read commitHash; do
    git diff-tree --name-status $commitHash

List all commits in a Git repository.

Remove empty commits in Git.


To find more neat Git commands and hacks, browse the Git category. Feel free to leave a comment below and if you find this tutorial useful, follow our official channel on Telegram.