Programming 1 min read

How to Push Empty Git Commits

On this page

Why would you do it?

#

Well, because you might need to trigger a build without making any changes to your project… and you might not have access to trigger the build manually.

How would you do it?

#

It’s like pushing a normal commit, except you add the ---allow-empty flag.
So the entire command becomes:

bash
git commit --allow-empty -m "Empty commit"

Git aliases

#

You could shorten the command with git aliases, which allow you to create shortcuts for frequently used git commands.
To setup a new git alias:

bash
git config --global alias.empty 'commit --allow-empty -m'

Now, instead of writing git commit --allow-empty -m "Empty commit" you could simply use git empty "Empty commit" and be done.

Will soon write a more in-depth article about git aliases.

NORMAL how-to-push-empty-git-commits.md [programming] utf-8 · unix · 1 min read Top
Discussion · 0

Got it working, or hit a snag?

Share your setup, a fix or a question. Markdown and code blocks work.

How comments and emails are handled: Privacy.