← homeProgramming (Програмування)

How to make an empty git commit?

How to make an empty git commit? Let's make an empty git commit. Why? Who knows, everyone has their own goals. In my case - to trigger CI.

Table of contentsClick link to navigate to the desired location
This content has been automatically translated from Ukrainian.
Making an empty git commit. Everyone has their own goals for this action. In my case - to trigger CI.
git commit --allow-empty -m "Your commit message"
In the working branch, you will most likely write the text in English, so:
git commit --allow-empty -m "Trigger Build"
Note the flag --allow-empty, it is what does the magic and allows you to make a commit without code changes.
And after that, you can push the code to remote:
git push origin main
main is the branch where the push will be executed. Also, read what origin means at the link if you don't know yet.

Why might an empty commit be needed?

Usually, it is needed to provoke (trigger) CI or some hook. That is, to run or test the launch of integrations, hooks, scripts, etc., without changes in the code. So you don't need to make any change in the code, for example, adding an empty line or some comment, to make a push.

🔥 More posts

All posts
What is immutability and mutability?
Programming (Програмування)Jun 19, '24 07:48

What is immutability and mutability?

What is immutability and mutability? A description of the term in the context of programming and ...

What is a function in programming?
Programming (Програмування)Jun 24, '24 18:15

What is a function in programming?

What is a function in programming? Example of a function in Ruby and JavaScript

Ruby library Gosu for creating 2D games
Programming (Програмування)Jun 29, '24 08:48

Ruby library Gosu for creating 2D games

Ruby library Gosu for creating 2D games. Description of the library for game development in Ruby ...