3

Is there a way to create an empty commit (i.e. no actual changes) in IntelliJ IDEA 2018.1 (using git with the Git Integration plugin)?

I'm looking for the equivalent of

git commit --allow-empty -m "foo"

but using GUI.

Trying to commit an empty changelist simply yields a "No changes detected" error message.

Attila Csipak
  • 756
  • 1
  • 12
  • 30

1 Answers1

4

No, there is no way to create an empty commit in IntelliJ GUI. To commit, one needs to have some changes in the project.

What is the usecase, btw? Why do you need an empty commit? I am asking because there could be another way to achieve what you want.

Dmitriy Smirnov
  • 5,816
  • 1
  • 14
  • 25
  • The other way is using CLI. I am writing a HOWTO article on version management for internal use, and I wanted to describe every step both using CLI and using IDEA GUI. Now it looks like some steps that can be done using CLI can not be reproduced using the IDEA GUI :-/ Not a big deal, but so far the IDEA integration plugin worked so well, it seemed we can tackle every scenario without ever using CLI. – Attila Csipak Jul 24 '18 at 04:06
  • Indeed, several command-line options are missing from IntelliJ GUI. That's because in IntelliJ we try to support workflows and specific use-cases instead of providing straight GUI for git commands. There are actually too many of them in git to provide controls for all of them without cluttering UI. – Dmitriy Smirnov Jul 24 '18 at 09:07
  • 4
    Since I have the same need, some info on the usecase: some organization rely on specially crafted commit messages to trigger specific actions (e.g. releases) in a CI pipeline. In such an environment, an empty commit makes more sense than a commit with a meaningless content when all you need to do is to "trigger" something. Please don't tell me how bad an idea this is, I don't make the policy unfortunately. – p91paul Feb 21 '19 at 08:29
  • A usecase. Using an IntelliJ IDE, I merge one branch into another one, solve conflicts, and the result is: lots of commits were merged in, but there are no changes. I cannot finish the merge from IDE. – Leksat Jul 18 '19 at 06:35
  • 1
    @Leksat it is not a use case for creating empty commits, but a bug/usability issue of merge operation in IDE - see https://youtrack.jetbrains.com/issue/IDEA-96188. Committing from such a state will not create an empty commit, but will conclude a merge instead, so this is must-have. Not so sure about ability to create empty commits (the `--allow-empty` flag support) per se. – Dmitriy Smirnov Jul 18 '19 at 15:37
  • 1
    Our use case is somewhat similar to that mentioned by @p91paul . We mark the start of feature branches with empty commits that have can be easily identified by a pattern. Makes searching and understanding complex git history somewhat easier. – Attila Csipak Aug 06 '20 at 11:18