2016-06-13 270 views
4

我按照這個教程:https://help.github.com/articles/signing-commits-using-gpg/gpg:跳過「XXBDXX4E」:密鑰不可用。 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 [email protected] 
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) <[email protected]> 
uid  [ultimate] Do Nhu Vy (Do Nhu Vy) <[email protected]> 
sub 2048R/C6B535A2 2016-06-10 

(我註冊3封電子郵件,GitHub上:[email protected][email protected][email protected]) 我已經錯了嗎?我如何簽署我的承諾?

回答

5

我也有同樣的問題。不幸的是,錯誤信息並沒有指出真正的問題....這是你沒有配置git來使用你正在使用的gpg程序,我懷疑它是gpg4win。[我只在Win機器上遇到過這種情況]

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

請運行上面的命令後跟下面的。

git config user.signingkey DABDD34E 

你需要重啓終端;並重新發出您的git commit命令。

希望這會有所幫助。

0

我在Windows 10上使用TortoiseGIT,現在我遇到了同樣的問題。

對我來說這解決了這個問題:

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