如何以加密方式对分支上的所有提交进行签名?

5 git pgp git-filter-branch

我有PGP密钥让我通过提交签名git commit -S.为了签署我的最后一次提交,我做了一个git commit -S --amend --no-edit并签署了我的提交.

现在,我想签署分支中的所有提交filtered.

我试过了: git filter-branch --commit-filter 'git commit -S --amend --no-edit'

它给了我一个错误信息:

$ git filter-branch --commit-filter 'git commit --amend --no-edit -S' HEAD
Rewrite 07b0ac12f5fe1d8963d7ae0ac7fbda50cb6e74a9 (1/10)gpg: skipped "Anubhav Saini <IAmAnubhavSaini@users.noreply.github.com>": secret key not available
gpg: signing failed: secret key not available
error: gpg failed to sign the data
fatal: failed to write commit object
could not write rewritten commit
Run Code Online (Sandbox Code Playgroud)

另一个问题:提出另一个git commit --amend --no-edit -S结果:

(filter-test)$ git commit -S --no-edit --amend

You need a passphrase to unlock the secret key for
user: "Anubhav Saini <iamanubhavsaini@gmail.com>"

[filter-test c5ea180] Removing defer and async from scripts
 4 files changed, 28 insertions(+), 28 deletions(-)
Run Code Online (Sandbox Code Playgroud)

问题

  1. 如何批量签名提交消息?
  2. 什么在实际上和幕后做出了另一个标志?

use*_*253 0

也许你应该设置一个gpg-agent,并为密码有效性设置一个适当的超时(足以运行整个重写序列)。请参阅此 Arch wiki 页面以获取帮助。因此,可以在重写之前输入密码一次,然后 gpg 的所有调用都将使用该解锁密钥一段时间。