Ad space (banner)
🌿Git Lessons
Lesson 47 / 59

Creating an Empty Commit with git commit --allow-empty

This lesson covers creating a commit with no changes with git commit --allow-empty. It's for anyone searching "git commit --allow-empty usage."

git commit --allow-empty lets you create a commit even when there's nothing changed at all. A normal commit is refused when there's nothing to commit, but this option makes it possible anyway, as a special case.

In Try It, run git commit --allow-empty -m "Re-run CI". Even with no file changes, a commit carrying the given message gets created.

A common early mistake is not seeing the point of this command — it looks pointless at first glance, but as the example below shows, it has a genuinely practical use, like re-triggering CI (an automated testing/deployment pipeline). In real teams, this empty-commit technique gets used as a way to re-run a CI tool that's triggered by pushes, without needing to actually change any code.

Git
Try it (type this into the pseudo terminal)
git commit --allow-empty -m "Re-run CI"

🧑‍💻 You can type this command into the Git pseudo terminal to try it yourself (this page itself has no interactive terminal).

Ad space (banner)
Ad space (in-article)