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

How to make an empty git commit?

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 Eng...

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?

Immutability and mutability are properties of objects (in programming and other fields) that dete...

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

What is a function in programming?

A function is the fundamental building block of programming that defines a set of instructions or...

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

Ruby library Gosu for creating 2D games

Gosu is a library for developing 2D games and graphical applications in the Ruby programming lang...

What does .map(&:name) mean in Ruby?
Programming (Програмування)Jul 28, '24 11:18

What does .map(&:name) mean in Ruby?

In Ruby, the map(&:name) construct is a shorthand for applying a method to each element of a ...