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
编辑:
当我尝试列出我的 key 时出现此错误???
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
最佳答案
您可以使用像 gpg4win 这样的 gpg GUI 来初始化您的 gnupg 环境( key ) , 关注 this tutorial ,或(更新)官方 gpg4win 文档“Gpg4win for Novices ”。
注意这个blog post添加以下警告:
I installed Gpg4win, which installs a nice GUI for managing keys and the GPG command line interface.
My ignorance of the process was clear as I repeatedly attempted to use the GUI (GNU Privacy Assistant – Key Manager) to create my key. That GUI appears to create valid keys, but wherever it stores the related key part files is not where the GPG command line expects to find them.
(注意:可能在 C:\Users\Name\AppData\Roaming\gnupg
上,目录名为 gnupg
而不是 .gnupg
)
Instead, be sure to use the command line client. Start with:
gpg --gen-key
If key creation fails, you might manually need to create the directory
c:users<USER>.gnupg
, which GPG will apparently not do on its own.
cd C:\Users\Name
mkdir .gnupg
xcopy C:\Users\Name\AppData\Roaming\gnupg .gnupg
The errors that I was seeing along the way were
gpg: no writable public keyring found
and:
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
如 roguib 所述在 the 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
,以确保确实推送了所有内容(或者什么都不会推送)。
关于Git GPG 错误签名标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16876817/