【问题标题】:GIT commit error - VSCODE in WSL2 (error: gpg failed to sign the data fatal: failed to write commit object)GIT 提交错误 - WSL2 中的 VSCODE(错误:gpg 未能签署数据致命:未能写入提交对象)
【发布时间】:2021-05-12 23:07:28
【问题描述】:

我已经安装了 VSCode

code --version

1.53.0 8490d3dde47c57ba65ec40dd192d014fd2113496 x64 Git 版本:

git --version

git 版本 2.27.0

我有活动的钥匙。当我提交时,我得到标题错误。我在命令行中收到错误并在 vscode 中单击提交。

GIT_TRACE=1 git commit -m "start"

11:50:45.606604 git.c:442 跟踪:内置:git commit -m 开始 11:50:45.649422 run-command.c:663 跟踪:run_command: /usr/bin/gpg --status-fd=2 -bsau “主动键”

错误:gpg 未能签署数据

致命:无法写入提交对象

gpg --status-fd=2 -bsau "active key"

[GNUPG:] KEY_CONSIDERED "活动密钥" 2

[GNUPG:] BEGIN_SIGNING H10

^C

gpg: 信号中断被捕获...正在退出

它一直挂到我停下来。 有任何想法吗?。谢谢。

【问题讨论】:

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


    【解决方案1】:

    我在 WSL2 (unbuntu 20.04) 下遇到了类似的问题,并且能够重现您的错误。

    初始情况:

    GPG 密钥可用。但要注意有很多过时的指令所以使用:https://docs.github.com/en/github/authenticating-to-github/generating-a-new-gpg-key

    gpg --full-generate-key 在我的情况下

    解决办法:

    1. 您将 git 与配置的 commit.gpgsign = true 一起使用,因为您在 UI 和控制台中收到错误。 如果这不是必需的,则在项目文件夹中本地停用签名: git config commit.gpgsign false 或全球 git config --global commit.gpgsign false

    2. 您想签名并使用 VSCode。 问题的核心是 WSL2 中的 GPG 安装,因为那是使用的。 GPG 代理丢失,Windows 无法解锁密钥。在 WSL2 中安装代理并进行配置。只要在 WSL2 终端下激活 GPG 密钥,就可以使用缓存状态。然后 VSCode 将在配置的时间内工作。 如果你想在Windows下输入密码,那么请阅读这里的解决方案:No GPG passphrase prompt in Visual Studio Code on Windows 10 for signed git commits using WSL2

    【讨论】:

    • 这正是我需要做的。非常感谢!
    【解决方案2】:

    我按照这些说明 https://www.39digits.com/signed-git-commits-on-wsl2-using-visual-studio-code 设法修复了我的 WSL2 设置

    最重要的是在Windows 10中安装GPG4Win...并添加~/.gnupg/gpg-agent.conf

    default-cache-ttl 34560000
    max-cache-ttl 34560000
    pinentry-program "/mnt/c/Program Files (x86)/GnuPG/bin/pinentry-basic.exe"
    

    Visual Studio Code 安装在 Windows 10 端,因此我们 提交时需要该图形密码输入密码 来自编辑器的代码。

    【讨论】:

      猜你喜欢
      • 2021-07-18
      • 2017-01-22
      • 1970-01-01
      • 2017-04-24
      • 1970-01-01
      • 2017-05-21
      • 2022-08-24
      • 2019-03-19
      • 1970-01-01
      相关资源
      最近更新 更多