我已经安装了 VSCode
code --version
1.53.0 8490d3dde47c57ba65ec40dd192d014fd2113496 x64 Git version:
git --version
git version 2.27.0
我有事件键。当我提交时,我收到标题错误。我在命令行中收到错误并在 vscode 中单击提交。
GIT_TRACE=1 git commit -m "start"
11:50:45.606604 git.c:442 trace: built-in: git commit -m start 11:50:45.649422 run-command.c:663 trace: run_command: /usr/bin/gpg --status-fd=2 -bsau "active-key"
错误:gpg 未能签署数据
致命:无法写入提交对象
gpg --status-fd=2 -bsau "active key"
[GNUPG:] KEY_CONSIDERED "ACTIVE KEY" 2
[GNUPG:] BEGIN_SIGNING H10
^C
gpg: signal Interrupt caught ... exiting
它一直挂到我停下来。
有任何想法吗?。谢谢你。
最佳答案
我在 WSL2(unbuntu 20.04)下遇到了类似的问题,并且能够重现您的错误。
初始情况:
GPG key 可用。但是要注意有很多过时的说明所以使用:https://docs.github.com/en/github/authenticating-to-github/generating-a-new-gpg-keygpg --full-generate-key
就我而言
解决方法:
commit.gpgsign = true
因为您在 UI 和控制台中收到错误。如果不需要,则在项目文件夹中本地停用签名:
git config commit.gpgsign false
或全局git config --global commit.gpgsign false
问题的核心是 WSL2 中的 GPG 安装,因为这就是使用的。 GPG 代理丢失,Windows 无法解锁 key 。在 WSL2 中安装代理并配置它。只要在 WSL2 终端下激活 GPG key ,就可以使用缓存状态。然后 VSCode 将在配置的时间内工作。
如果你想在 Windows 下输入密码,那么请阅读这里的解决方案:No GPG passphrase prompt in Visual Studio Code on Windows 10 for signed git commits using WSL2
关于GIT 提交错误 - WSL2 中的 VSCODE(错误 : gpg failed to sign the data fatal: failed to write commit object),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66116949/