An Empty Commit Is A Useful Commit!

useful.jpeg

The motivation

Sometimes you need to perform a GIT commit without changing any file in the repository:

  • For triggering a new build
  • For testing the workflow (GIT hooks, builds, releases, etc.)

The HOW-TO

GIT commit has a special command switch for this purpose:

–allow-empty

This switch performs a simple commit with no files changes but with a complete GIT object as of a regular commit.

For example, the following command:

git commit –allow-empty -m “Empty test commit”

creates the following object (screenshot from Atlassian SourceTree):

empty-commit-1.png

empty-commit-2.png

Simple and useful…

Enjoy,

Yoram Michaeli - yorammi@tikalk.com