我正在尝试使用git命令行在GitHub中创建签名标签.我用(样本)用户名生成了一个GPG密钥Full Name (skytreader) <fullname@gmail.com>.完成后,我尝试创建一个签名标签.但是我收到以下错误:
gpg: skipped "full <fullname@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
Run Code Online (Sandbox Code Playgroud)
我想我只需要用指定的用户名创建另一个密钥.但是,输入名称"full",gpg抱怨我的名字至少应该是5个字符.
如何在git中使用此密钥?
我是否更改了git用于使用GPG签署我的标签的用户名,以便获得至少5个字符长的真实姓名?
小智 39
首先,您需要检查您的ID是否有gpg密钥.
$ gpg --list-key
Run Code Online (Sandbox Code Playgroud)
如果你有这样的东西:
- pub 2048R/6AB3587A 2013-05-23
- uid xxx(gpg for xxx)
- sub 2048R/64CB327A 2013-05-23
如果没有gpg键.你应该创造
$ gpg --gen-key
Run Code Online (Sandbox Code Playgroud)
接下来你有这个输出:
gpg(GnuPG)2.0.14; 版权所有(C)2009 Free Software Foundation,Inc.这是免费软件:您可以自由更改和重新分发它.在法律允许的范围内,不提供任何担保.
请选择您想要的密钥类型:
- (1)RSA和RSA(默认)
- (2)DSA和Elgamal
- (3)DSA(仅限签名)
- (4)RSA(仅限签名)
你的选择?RSA密钥长度可以在1024到4096位之间.你想要什么密钥?(2048)
请求的密钥大小为2048位
请指定密钥的有效期.Run Code Online (Sandbox Code Playgroud)0 = key does not expire <n> = key expires in n days <n>w = key expires in n weeks <n>m = key expires in n months <n>y = key expires in n years密钥有效吗?(0)
密钥不会过期这
是正确的吗?(是/否)yRun Code Online (Sandbox Code Playgroud)GnuPG needs to construct a user ID to identify your key. Real name: xxx Email address: xxx@example.com Comment: gpg for xxx You selected this USER-ID: "xxx(gpg for xxx) <xxx@example.com>" Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit? O You need a Passphrase to protect your secret key. can't connect to `/xxx/.gnupg/S.gpg-agent': No such file or directory We need to generate a lot of random bytes. It is a good idea to perform some other action (type on the keyboard, move the mouse, utilize the disks) during the prime generation; this gives the random number generator a better chance to gain enough entropy.
Chr*_*her 16
提交者名称位于您的~/.gitconfig文件中.将该条目更改为真实姓名(无论如何,这是您想要提交的方式).您可以在您喜欢的编辑器中编辑该文件,或者只发出:
git config --global user.name "<name>"
Run Code Online (Sandbox Code Playgroud)
如果您已生成密钥,则可以告诉git使用该特定密钥,而无需担心您的git用户ID(名称+电子邮件)与GPG密钥的ID之间的匹配.您应该让您的git user.email匹配GPG密钥上的一封电子邮件,以便签名标签或提交对其他用户有用.
要设置计算机上全局使用的密钥,请使用以下命令设置git global config:
git config --global user.signingkey 6AB3587A
Run Code Online (Sandbox Code Playgroud)
或者,您可以user.signingkey仅为当前存储库设置:
git config user.signingkey 6AB3587A
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
18549 次 |
| 最近记录: |