GIT 提交错误 - WSL2 中的 VSCODE(错误 : gpg failed to sign the data fatal: failed to write commit object)

标签 git visual-studio-code git-commit gnupg

我已经安装了 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就我而言
解决方法:

  • 您使用 git 配置了 commit.gpgsign = true因为您在 UI 和控制台中收到错误。
    如果不需要,则在项目文件夹中本地停用签名:git config commit.gpgsign false或全局git config --global commit.gpgsign false
  • 你想签署和使用 VSCode。
    问题的核心是 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/

    相关文章:

    git - Visual Studio 2013 删除已删除的 git 分支

    python - 使用 Python 在 Visual Studio Code 中意外缩进

    git 从远程仓库 pull 所有分支

    git - 从 git 历史记录中删除垃圾邮件

    visual-studio-code - Visual Studio Code 突出显示标签

    python - VSCode 调试器自动附加到子进程

    github - GitHub Desktop 中的摘要和描述有什么区别?

    git - 如何更改过去的提交以包含丢失的文件?

    git - 如何从 git pull 请求中排除提交?

    git - 哪个提交有这个 Blob ?