How to create an empty commit via GUI in IntelliJ IDEA 2018.1 + Git Integration plugin?
Asked Answered
B

1

9

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.

Birthstone answered 23/7, 2018 at 9:30 Comment(2)
This might be something you have to do on the command line...Menial
@Menial Yes, I know. I was just curious if there's any GUI method to this which escaped my attention so far.Birthstone
N
5

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.

Nimocks answered 23/7, 2018 at 10:57 Comment(8)
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.Birthstone
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.Nimocks
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.Marcos
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.Frawley
@Frawley it is not a use case for creating empty commits, but a bug/usability issue of merge operation in IDE - see 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.Nimocks
Our use case is somewhat similar to that mentioned by @Marcos . 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.Birthstone
On my case, i use an external issue tracker that transit issues automatically when you open a Draft PR, so our workflow is: 1) create Draft PR, 2) start implementation, 3) Remove Draft to transit to code review, 4) merge the PR to transit to Done. To create a PR i need at least 1 commit. When starting the best option is to create an empty commit. While using gitlab this was not a concern because you can create an empty MR. On github that's not possible.Amarillas
Empty commits are sometimes used to mark a release, see e.g. pandas.pydata.org/docs/development/maintaining.html#releaseMemo

© 2022 - 2024 — McMap. All rights reserved.