7

i can't commit with IntelliJ and an activated gpg in config. Currently I can only do this with git bash manuel. I use windows and i found a lot of informations for OSX but that didn't helped me.

How can I use VCS in IntelliJ without doing anything about git bash?

This is the error from IntelliJ when i try to commit something.

11:52   Commit failed with error
        0 files committed, 1 file failed to commit: update
        gpg failed to sign the data
        failed to write commit object
Scarpex
  • 71
  • 1
  • 4
  • For Windows, some instructions are [in this answer](https://stackoverflow.com/a/46884134/4126843) which worked for automatically signing commits using IntelliJ. but OSX may be different at some points – PHPirate Sep 18 '18 at 12:24

3 Answers3

6

IDE is not a terminal and cannot handle the prompt issue by gpg on the command line.

As a workaround, you could create a wrapper and tell git to use it as gpg app.

Wrapper code:

# file /home/user/gpg-no-tty.sh
#!/bin/bash
/usr/bin/gpg --batch --no-tty "$@" 

and then set your git config for the repo where you want to gpg sign commits:

[gpg]
        program = /home/user/gpg-no-tty.sh

See this comment for details

Dmitrii Smirnov
  • 7,073
  • 1
  • 19
  • 29
2

In Windows + (IntelliJ / AndroidStudio), your global git config should look like this:

user.name=<username>
user.email=<email>
user.signingkey=<key>
commit.gpgsign=true
gpg.program=<path to gpg.exe>
Bram Van Dyck
  • 109
  • 10
1

2023 answer:

In your ~/.gnupg/gpg.conf change (or add) the following setting:

pinentry-mode ask

If you have a pinentry-mac program available (for macOS) the GUI prompt will appear upon every new passphrase request.

The gpg+Intellij setup guide can be found here: https://www.jetbrains.com/help/idea/set-up-GPG-commit-signing.html#set-up-gpg-keys

Yevhenii Dovhaniuk
  • 1,073
  • 5
  • 11