【问题标题】:Git GPG error signing tagsGit GPG 错误签名标签
【发布时间】:2013-06-01 20:11:48
【问题描述】:

gotOK 说到 Git,我还是个新手。所以我决定阅读 Scott Chacon 的 Pro Git。顺便说一句,好书,强烈推荐。

无论如何到了关于签名标签的部分。 要使用 GPG 签署标签,您必须设置一个私钥,就像我做的那样。 然而,当我跑的时候:

git tag -s v1.6 -m "my signed 1.6 tag"

我得到了以下信息:

C:\Users\Name\Desktop\git>git tag -s v1.6 -m "my signed 1.6 tag"
gpg: error loading `iconv.dll': The specified module could not be found.

gpg: please see http://www.gnupg.org/download/iconv.html for more information
gpg: skipped "Name <name@gmail.com>": secret key not available
gpg: signing failed: secret key not available
error: gpg failed to sign the data
error: unable to sign the tag

所以,我按照错误消息告诉我的去做,然后转到链接并按照说明进行操作。我将 iconv.dll 复制到包含 gpg.exe (\Git\bin) 的文件夹中。再次运行命令,得到:

C:\Users\Name\Desktop\git>git tag -s v1.6 -m "my signed 1.6 tag"
gpg: skipped "Name <name@gmail.com>": secret key not available
gpg: signing failed: secret key not available
error: gpg failed to sign the data
error: unable to sign the tag

编辑:

当我尝试列出我的密钥时,我得到了这个错误???

Name@NAME-PC ~
$ gpg --list-secret-keys
gpg: keyblock resource `c:/Users/Name/.gnupg\secring.gpg': file open error
gpg: keyblock resource `c:/Users/Name/.gnupg\pubring.gpg': file open error
gpg: fatal: c:/Users/Name/.gnupg: directory does not exist!
secmem usage: 0/0 bytes in 0/0 blocks of pool 0/32768

【问题讨论】:

    标签: git gnupg


    【解决方案1】:

    您可以使用gpg4win 之类的 gpg GUI、this tutorial 或(更新的)官方 gpg4win 文档“Gpg4win for Novices”来初始化您的 gnupg 环境(密钥)。

    请注意,此 blog post 添加以下警告:

    我安装了 Gpg4win,它安装了一个很好的 GUI 用于管理密钥和 GPG 命令行界面。
    当我反复尝试使用 GUI(GNU 隐私助手 - 密钥管理器)来创建我的密钥时,我对这个过程的无知是显而易见的。 该 GUI 似乎创建了有效的密钥,但它存储相关密钥部分文件的位置并不是 GPG 命令行期望找到它们的位置

    (注意:可能在C:\Users\Name\AppData\Roaming\gnupg,目录名为gnupg,而不是.gnupg

    请务必使用命令行客户端。开始:

    gpg --gen-key
    

    如果密钥创建失败,您可能需要手动创建目录c:users&lt;USER&gt;.gnupg,而 GPG 显然不会自行创建

    cd C:\Users\Name 
    mkdir .gnupg
    xcopy C:\Users\Name\AppData\Roaming\gnupg .gnupg
    

    我在此过程中看到的错误是

    gpg: no writable public keyring found
    

    和:

    signing failed: secret key not available
    

    注意:一旦您的 gnupg 就位,如果您仍然有错误消息,请执行 add the the (gnupg) key-id you want to use when signing your tag:

    git tag -u 'key-id' -s -m "some comment" some-tag 
    

    正如roguibthe comments 中所指出的,如果您want to see that tag on the remote side,您将需要:

    • git push --tags
    • 或者,由于 Git 2.4.1 和 git config --global push.followTags true,一个简单的 git push 就足够了。
    • 并且,仍然使用 Git 2.4.x,您可以添加 git push --atomic,以确保确实推送了所有内容(或者什么都不会推送)。

    【讨论】:

    • 如果你仍然想使用 gui,或者已经用它创建了一个密钥,你可以通过 MKLINK /D C:\Users\NAME\.gnupg C:\Users\NAME\AppData 链接目录\漫游\gnupg
    • 如果你也想在 GitHub 上看到标签,记得用git push --tags &lt;remote&gt; 推送它。
    • @roguib 谢谢。我已将您的评论包含在答案中以提高知名度。实际上,使用git config --global push.followTags true,一个简单的git push 就足够了。
    猜你喜欢
    • 2017-04-24
    • 1970-01-01
    • 2017-05-21
    • 2019-03-19
    • 1970-01-01
    • 2016-04-16
    • 1970-01-01
    • 2021-05-08
    • 1970-01-01
    相关资源
    最近更新 更多