Git logo

Git: create empty commit to trigger an action

By

in

Sometimes it’s necessary to trigger an action for CI/CD, e.g. when you use GitLab. To do this without any changes on the code base, you can create an empty commit. For this, git has a command:

git commit --allow-empty -m "Trigger Build"

This is also described in the Git documentation:

--allow-empty
Usually recording a commit that has the exact same tree as its sole parent commit is a mistake, and the command prevents you from making such a commit. This option bypasses the safety, and is primarily for use by foreign SCM interface scripts.

https://git-scm.com/docs/git-commit/2.31.0#Documentation/git-commit.txt—allow-empty


Comments

One response to “Git: create empty commit to trigger an action”

  1. That’s it! Thx 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *