+6

Commit: allow to create an empty commit (git commit --allow-empty -m "...")

Geofrey van Hecke 7 years ago updated by Michael Ryan 5 months ago 6

This feature will expose an easy way through the UI to do the same as git commit --allow-empty -m "my comment".


There is a typical use case:

As a developer

When I add an empty commit to my checkout branch

And when I push it to my remote branch

Then it the Continuous Integration server triggers a new build.

Have you already tried to define an external tool?

I also use empty commits, currently I create one in every new repository (that helps as a workaround to difficulties with modifying root commit in git, and other minor problems).


I think it can be reasonable to add a new button to error message "There is nothing to commit".

SmartGit already creates an empty commit when initializing a new Git repository.

... aAnd now also if you have the repository initialized outside SmartGit and do the first commit.

There are tricks on ci/cd pipelines driven by messages on empty commits.

+1

I'm not sure when it was introduced, but there's now a low-level property in Preferences to enable this feature.

  1. Open Preferences
  2. Click on the Low-Level Properties category
  3. Click the I accept the risk! button to open the Low-Level Properties panel
  4. Enter "empty" in the search filter to locate the feature
  5. Double-click the "commit.allowToCreateEmpty" key to edit its value
  6. Select the true radio option and click the OK button
  7. Click OK to close Preferences panel

You should now be able to select a workspace in SmartGit and click Commit... from the context menu to create an empty commit.