gpg:跳过“XXBDXX4E”:密钥不可用。 gpg:签名失败:密钥不可用

时间:2016-06-13 02:17:05

标签: git github

我遵循本教程:https://help.github.com/articles/signing-commits-using-gpg/

我尝试在提交时签名: https://github.com/spring-guides/tut-spring-boot-oauth2/commit/824f418ab9d04114b14a90f7c19b4b8d6dda67b7

enter image description here

但错误:

C:\Users\Administrator\Desktop\foo\test_gpg>git commit -m "test"
gpg: skipped "DABDD34E": secret key not available
gpg: signing failed: secret key not available
error: gpg failed to sign the data
fatal: failed to write commit object

enter image description here enter image description here enter image description here enter image description here

我的配置:

C:\Users\Administrator\Desktop\foo\test_gpg>git config --list --show-origin
file:"C:\\ProgramData/Git/config"       core.symlinks=false
file:"C:\\ProgramData/Git/config"       core.autocrlf=true
file:"C:\\ProgramData/Git/config"       core.fscache=true
file:"C:\\ProgramData/Git/config"       color.diff=auto
file:"C:\\ProgramData/Git/config"       color.status=auto
file:"C:\\ProgramData/Git/config"       color.branch=auto
file:"C:\\ProgramData/Git/config"       color.interactive=true
file:"C:\\ProgramData/Git/config"       help.format=html
file:"C:\\ProgramData/Git/config"       http.sslcainfo=C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt
file:"C:\\ProgramData/Git/config"       diff.astextplain.textconv=astextplain
file:"C:\\ProgramData/Git/config"       rebase.autosquash=true
file:"C:\\Program Files\\Git\\mingw64/etc/gitconfig"    credential.helper=manager
file:C:/Users/Administrator/.gitconfig  user.name=donhuvy
file:C:/Users/Administrator/.gitconfig  user.email=donhuvy@hotmail.com
file:C:/Users/Administrator/.gitconfig  user.signingkey=DABDD34E
file:C:/Users/Administrator/.gitconfig  commit.gpgsign=true
file:C:/Users/Administrator/.gitconfig  use.signingkey=DABDD34E
file:.git/config        core.repositoryformatversion=0
file:.git/config        core.filemode=false
file:.git/config        core.bare=false
file:.git/config        core.logallrefupdates=true
file:.git/config        core.symlinks=false
file:.git/config        core.ignorecase=true
file:.git/config        core.hidedotfiles=dotGitOnly
file:.git/config        remote.origin.url=https://github.com/donhuvy/test_gpg.git
file:.git/config        remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
file:.git/config        branch.master.remote=origin
file:.git/config        branch.master.merge=refs/heads/master
file:.git/config        commit.gpgsign=true

C:\Users\Administrator\Desktop\foo\test_gpg>gpg --list-key
C:/Users/Administrator/AppData/Roaming/gnupg/pubring.gpg
--------------------------------------------------------
pub   2048R/DABDD34E 2016-06-10
uid       [ultimate] donhuvy (Do Nhu Vy) <v@vyhn.net>
uid       [ultimate] Do Nhu Vy (Do Nhu Vy) <v@vyhn.net>
sub   2048R/C6B535A2 2016-06-10

(我使用GitHub注册了3封电子邮件:v@vyhn.netdonhuvy@hotmail.comxxxxx@gmail.com) 我错了什么?我如何签署我的提交?

2 个答案:

答案 0 :(得分:6)

我也有同样的问题。不幸的是,错误消息没有指出真正的问题....这是你没有配置git使用你正在使用的gpg程序,我怀疑是gpg4win。[我只在Win机器上遇到过这个]

git config --global gpg.program "C:/Program Files (x86)/GNU/GnuPG/gpg2.exe"

请运行以上命令,然后执行以下操作。

git config user.signingkey DABDD34E

你需要重启终端;并重新发出git commit命令。

希望这有帮助。

答案 1 :(得分:0)

我在Windows 10上使用TortoiseGIT,我现在遇到了同样的问题。

对我来说,这解决了这个问题:

git config --global gpg.program "c:\Program Files (x86)\GnuPG\bin\gpg.exe"