implenton - Mészáros Róbert

Commit without file changes in Git

If you have a workflow where commits trigger certain events (e.g., CI/CD), and you have to do a test commit just to see what happens, then use the --alow-empty flag instead of committing a dummy change in a file.

git commit -m 'Test CI' --allow-empty

The Git man page describes the -allow-empy flag like this:

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.

SCM stands for source-control management. Git is one of the many options; others are Subversion, CVS, etc.

Back to all posts