Occasionally you see commit messages like:

trigger build

empty commit for CI

Developers push these commits to re-run continuous integration (CI) after a failure due to a flaky test or an intermittent network error. The commits often contain an innocuous change such as adding a blank line in a README file or changing one character in a code comment.

The problem Link to heading

The developer doesn’t actually want to change anything in the project—they want to trigger a new build. But, by default, the git commit command prevents creating empty commits:

$ git commit
On branch my-feature
nothing to commit, working tree clean

Empty Git commits Link to heading

To avoid changing the project, specify the --allow-empty option when committing:

$ git commit --allow-empty -m "Empty commit"
[my-feature 5e1cb99] Empty commit

This allows the developer to push a truly empty commit to trigger the build.

Alternatives Link to heading

Although pushing an empty commit to trigger a build accomplishes the goal, there’s often a better way. For example, GitHub Actions supports re-running workflows and jobs from the UI.

References Link to heading