If you're using a GPG key that matches your committer identity and your verified email address associated with your account on your GitHub Enterprise Server instance, then you can begin signing commits and signing tags.
-
打开终端终端Git Bash。
-
使用
gpg --list-secret-keys --keyid-format=long
命令列出� 拥有其公钥和私钥的长形式 GPG 密钥。 签名提交或� �记需要私钥。Shell $ gpg --list-secret-keys --keyid-format=long
注意:Linux 上的某些 GPG 安装可能需要改用
gpg2 --list-keys --keyid-format LONG
查看现有密钥的列表。 在这种情况下,还需要通过运行git config --global gpg.program gpg2
来配置 Git 以使用gpg2
。 -
从 GPG 密钥列表中复制您想要使用的 GPG 密钥 ID 的长形式。 在本例中,GPG 密钥 ID 为
3AA5C34371567BD2
:Shell $ gpg --list-secret-keys --keyid-format=long /Users/hubot/.gnupg/secring.gpg ------------------------------------ sec 4096R/3AA5C34371567BD2 2016-03-10 [expires: 2017-03-10] uid Hubot <hubot@example.com> ssb 4096R/42B317FD4BA89E7A 2016-03-10
-
Enter
gpg --edit-key GPG key ID
, substituting in the GPG key ID you'd like to use. In the following example, the GPG key ID is3AA5C34371567BD2
:$ gpg --edit-key 3AA5C34371567BD2
-
Enter
gpg> adduid
to add the user ID details.$ gpg> adduid
-
Follow the prompts to supply your real name, email address, and any comments. You can modify your entries by choosing
N
,C
, orE
.Real Name: OCTOCAT Email address: "octocat@github.com" Comment: GITHUB-KEY Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit?
-
Enter
O
to confirm your selections. -
Enter your key's passphrase.
-
Enter
gpg> save
to save the changes$ gpg> save
-
Enter
gpg --armor --export GPG key ID
, substituting in the GPG key ID you'd like to use. In the following example, the GPG key ID is3AA5C34371567BD2
:$ gpg --armor --export 3AA5C34371567BD2 # Prints the GPG key, in ASCII armor format
-
Upload the GPG key by adding it to your GitHub account.