How to push an empty git commit

We’ve all been there. We need to trigger something from a commit to a git
repository, and instead of triggering the build directly, we end up tweaking
something in a file, committing it, and pushing it.

It’s usually just adding a blank line (and subsequently removing it, depending
on where in the dance we are) to the file. Couple that with some
toxic waste of a commit message like bump.

While this post won’t help you get rid of the crappy commit message, it will
save you a step by showing you how to perform a git commit without changing any files.

To make this magic happen, we need to include the aptly named --allow-empty argument when running git commit:

git commit --allow-empty -m "bump"

With our new, and very empty, commit created, simply git push as you normally would!

Josh Sherman - The Man, The Myth, The Avatar

About Josh

Husband. Father. Pug dad. Musician. Founder of Holiday API, Head of Engineering and Emoji Specialist at Mailshake, and author of the best damn Lorem Ipsum Library for PHP.

If you found this article helpful, please consider buying me a coffee.