设置和配置
获取和创建项目
基本快照
分支与合并
共享和更新项目
检查和比较
打补丁
调试
电子邮件
外部系统
服务器管理
指南
管理
底层命令
- 2.40.1 → 2.52.0 无更改
-
2.40.0
2023-03-12
- 2.38.1 → 2.39.5 无更改
-
2.38.0
2022-10-02
描述
Git 在多个地方使用加密签名,目前包括对象(标签、提交、合并标签)和事务(推送)。在所有情况下,即将创建对象或事务的命令都会从中确定一个有效负载,调用外部程序获取该有效负载的独立签名(对于 PGP 签名是 gpg -bsa),并将签名嵌入到对象或事务中。
签名以“ASCII Armor”标题行开头,以尾部行结束,具体取决于签名类型(由 gpg.format 选择,请参见 git-config[1])。对于 gpg.format 值,它们是:
gpg(PGP)-
-----BEGINPGPSIGNATURE-----和-----ENDPGPSIGNATURE-----。或者,如果 gpg 被告知生成 RFC1991 签名,则为-----BEGINPGPMESSAGE-----和-----ENDPGPMESSAGE-----。 ssh(SSH)-
-----BEGINSSHSIGNATURE-----和-----ENDSSHSIGNATURE-----。 x509(X.509)-
-----BEGINSIGNEDMESSAGE-----和-----ENDSIGNEDMESSAGE-----。
签名有时会作为正常有效负载的一部分出现(例如,已签名的标签会将签名块附加到其适用的有效负载之后),有时会出现在对象头的某个值中(例如,合并了已签名的标签的合并提交将在其“mergetag”头部包含整个标签内容)。在后一种情况下,对象头通常的多行格式化规则适用。也就是说,第二行及后续行会以一个空格 (SP) 作为前缀,表示该行是从前一行延续的。
这甚至适用于本来是空的一行。在以下示例中,以空白字符结尾的行末会用 $ 符号高亮显示;如果您尝试手动重新创建这些示例,请勿复制粘贴——它们主要是为了突出显示某些行末的额外空白。
已签名的有效负载以及签名的嵌入方式取决于对象或事务的类型。
标签签名
-
创建者:
gittag-s -
有效负载:注解标签对象
-
嵌入方式:将签名附加到未签名的标签对象
-
示例:主题为
signedtag的标签signedtag
object 04b871796dc0420f8e7561a895b52484b701d51a type commit tag signedtag tagger C O Mitter <committer@example.com> 1465981006 +0000 signed tag signed tag message body -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAABAgAGBQJXYRhOAAoJEGEJLoW3InGJklkIAIcnhL7RwEb/+QeX9enkXhxn rxfdqrvWd1K80sl2TOt8Bg/NYwrUBw/RWJ+sg/hhHp4WtvE1HDGHlkEz3y11Lkuh 8tSxS3qKTxXUGozyPGuE90sJfExhZlW4knIQ1wt/yWqM+33E9pN4hzPqLwyrdods q8FWEqPPUbSJXoMbRPw04S5jrLtZSsUWbRYjmJCHzlhSfFWW4eFd37uquIaLUBS0 rkC3Jrx7420jkIpgFcTI2s60uhSQLzgcCwdA2ukSYIRnjg/zDkj8+3h/GaROJ72x lZyI6HWixKJkWw8lE9aAOD9TmTW9sFJwcVAzmAuFX2kUreDUKMZduGcoRYGpD7E= =jpXa -----END PGP SIGNATURE-----
-
验证方式:
gitverify-tag[-v] 或gittag-v
gpg: Signature made Wed Jun 15 10:56:46 2016 CEST using RSA key ID B7227189 gpg: Good signature from "Eris Discordia <discord@example.net>" gpg: WARNING: This key is not certified with a trusted signature! gpg: There is no indication that the signature belongs to the owner. Primary key fingerprint: D4BE 2231 1AD3 131E 5EDA 29A4 6109 2E85 B722 7189 object 04b871796dc0420f8e7561a895b52484b701d51a type commit tag signedtag tagger C O Mitter <committer@example.com> 1465981006 +0000 signed tag signed tag message body
提交签名
-
创建者:
gitcommit-S -
有效负载:提交对象
-
嵌入方式:头部条目
gpgsig(内容前有一个空格) -
示例:主题为
signedcommit的提交
tree eebfed94e75e7760540d1485c740902590a00332 parent 04b871796dc0420f8e7561a895b52484b701d51a author A U Thor <author@example.com> 1465981137 +0000 committer C O Mitter <committer@example.com> 1465981137 +0000 gpgsig -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 $ iQEcBAABAgAGBQJXYRjRAAoJEGEJLoW3InGJ3IwIAIY4SA6GxY3BjL60YyvsJPh/ HRCJwH+w7wt3Yc/9/bW2F+gF72kdHOOs2jfv+OZhq0q4OAN6fvVSczISY/82LpS7 DVdMQj2/YcHDT4xrDNBnXnviDO9G7am/9OE77kEbXrp7QPxvhjkicHNwy2rEflAA zn075rtEERDHr8nRYiDh8eVrefSO7D+bdQ7gv+7GsYMsd2auJWi1dHOSfTr9HIF4 HJhWXT9d2f8W+diRYXGh4X0wYiGg6na/soXc+vdtDYBzIxanRqjg8jCAeo1eOTk1 EdTwhcTZlI0x5pvJ3H0+4hA2jtldVtmPM4OTB0cTrEWBad7XV6YgiyuII73Ve3I= =jKHM -----END PGP SIGNATURE----- signed commit signed commit message body
-
验证方式:
gitverify-commit[-v](或gitshow--show-signature)
gpg: Signature made Wed Jun 15 10:58:57 2016 CEST using RSA key ID B7227189 gpg: Good signature from "Eris Discordia <discord@example.net>" gpg: WARNING: This key is not certified with a trusted signature! gpg: There is no indication that the signature belongs to the owner. Primary key fingerprint: D4BE 2231 1AD3 131E 5EDA 29A4 6109 2E85 B722 7189 tree eebfed94e75e7760540d1485c740902590a00332 parent 04b871796dc0420f8e7561a895b52484b701d51a author A U Thor <author@example.com> 1465981137 +0000 committer C O Mitter <committer@example.com> 1465981137 +0000 signed commit signed commit message body
合并标签签名
-
创建者:在已签名的标签上执行
gitmerge -
有效负载/嵌入方式:整个已签名的标签对象作为头部条目
mergetag嵌入到(合并)提交对象中。 -
示例:合并上面提到的已签名标签
signedtag
tree c7b1cff039a93f3600a1d18b82d26688668c7dea parent c33429be94b5f2d3ee9b0adad223f877f174b05d parent 04b871796dc0420f8e7561a895b52484b701d51a author A U Thor <author@example.com> 1465982009 +0000 committer C O Mitter <committer@example.com> 1465982009 +0000 mergetag object 04b871796dc0420f8e7561a895b52484b701d51a type commit tag signedtag tagger C O Mitter <committer@example.com> 1465981006 +0000 $ signed tag $ signed tag message body -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 $ iQEcBAABAgAGBQJXYRhOAAoJEGEJLoW3InGJklkIAIcnhL7RwEb/+QeX9enkXhxn rxfdqrvWd1K80sl2TOt8Bg/NYwrUBw/RWJ+sg/hhHp4WtvE1HDGHlkEz3y11Lkuh 8tSxS3qKTxXUGozyPGuE90sJfExhZlW4knIQ1wt/yWqM+33E9pN4hzPqLwyrdods q8FWEqPPUbSJXoMbRPw04S5jrLtZSsUWbRYjmJCHzlhSfFWW4eFd37uquIaLUBS0 rkC3Jrx7420jkIpgFcTI2s60uhSQLzgcCwdA2ukSYIRnjg/zDkj8+3h/GaROJ72x lZyI6HWixKJkWw8lE9aAOD9TmTW9sFJwcVAzmAuFX2kUreDUKMZduGcoRYGpD7E= =jpXa -----END PGP SIGNATURE----- Merge tag 'signedtag' into downstream signed tag signed tag message body # gpg: Signature made Wed Jun 15 08:56:46 2016 UTC using RSA key ID B7227189 # gpg: Good signature from "Eris Discordia <discord@example.net>" # gpg: WARNING: This key is not certified with a trusted signature! # gpg: There is no indication that the signature belongs to the owner. # Primary key fingerprint: D4BE 2231 1AD3 131E 5EDA 29A4 6109 2E85 B722 7189
-
验证方式:默认情况下,验证信息已嵌入到合并提交消息中,或者通过
gitshow--show-signature进行验证。
commit 9863f0c76ff78712b6800e199a46aa56afbcbd49
merged tag 'signedtag'
gpg: Signature made Wed Jun 15 10:56:46 2016 CEST using RSA key ID B7227189
gpg: Good signature from "Eris Discordia <discord@example.net>"
gpg: WARNING: This key is not certified with a trusted signature!
gpg: There is no indication that the signature belongs to the owner.
Primary key fingerprint: D4BE 2231 1AD3 131E 5EDA 29A4 6109 2E85 B722 7189
Merge: c33429b 04b8717
Author: A U Thor <author@example.com>
Date: Wed Jun 15 09:13:29 2016 +0000
Merge tag 'signedtag' into downstream
signed tag
signed tag message body
# gpg: Signature made Wed Jun 15 08:56:46 2016 UTC using RSA key ID B7227189
# gpg: Good signature from "Eris Discordia <discord@example.net>"
# gpg: WARNING: This key is not certified with a trusted signature!
# gpg: There is no indication that the signature belongs to the owner.
# Primary key fingerprint: D4BE 2231 1AD3 131E 5EDA 29A4 6109 2E85 B722 7189