IntelliJ Idea GPG签名数据失败

7

我无法在配置了激活的gpg的IntelliJ中提交。目前,我只能通过git bash手动进行提交。我使用的是Windows系统,并且我找到了很多针对OSX的信息,但这并没有帮助我。

我该如何在IntelliJ中使用版本控制而不需要使用git bash?

这是当我尝试提交内容时从IntelliJ中出现的错误。

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

对于Windows,此答案中提供了一些指令,可以在IntelliJ中自动签署提交。但是在OSX上可能会有所不同。 - PHPirate
3个回答

6

IDE不是终端,无法处理命令行中gpg的提示问题。

可以采用一种绕过方式,创建一个包装器,并告诉git使用它作为gpg应用程序。

包装器代码:

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

然后在您想要对其进行gpg签名的repo中设置git配置:

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

详见此评论


请在您的问题中不仅包含链接,还要包含实际的解决方法。 - Jens Schauder
这在git 2.29.2、gpg 2.2.27和Pycharm 2020.3.5上无法工作。 - AmphotericLewisAcid

2
在 Windows + (IntelliJ / AndroidStudio) 中,您的全局 git 配置应该如下所示:

Original Answer 翻译成 "最初的回答"

user.name=<username>
user.email=<email>
user.signingkey=<key>
commit.gpgsign=true
gpg.program=<path to gpg.exe>

1

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接