gpt4 book ai didi

git - 如何配置 git 始终对标签进行签名?

转载 作者:太空狗 更新时间:2023-10-29 12:52:28 25 4
gpt4 key购买 nike

我使用的少数存储库需要对所有标签进行签名,有时我忘记将 -s 添加到 git tag,或者更糟的是,我使用不了解标签的 git GUI。

有没有办法将 GIT 配置为始终对标签进行签名?

我提到我尝试将以下 hack(s) 添加到 .gitconfig 但它没有任何效果,标签是在没有签名的情况下创建的,除非我在 cli 上手动提到 -s。

[alias]
tag = tag -s

[tag]
forceSignAnnotated = true

[commit]
gpgsign = true

最佳答案

Git 2.23(2019 年第 3 季度)更新,you now have git config tag.gpgSign true !


原始答案(2018 年 6 月)

虽然 git 标签没有“默认签名”模式,the documentation mentions :

Once you have a private key to sign with, you can configure Git to use it for signing things by setting the user.signingkey config setting.

git config --global user.signingkey 0A46826A

By default, git tag in sign-with-default mode (-s) will use your committer identity (of the form Your Name <your@email.address>) to find a key.
If you want to use a different default key, you can specify it in the repository configuration as follows:

[user]
signingKey = <gpg-keyid>

注意:如果您使用 -m 创建标签选项 ( tag -m "a comment" myTag ),使它们注释

来自 git tag man page :

If -m <msg> or -F <file> is given and -a, -s, and -u <keyid> are absent, -a is implied.

所以你可以:

  • 为 git 标签定义别名(不是 add -s )
  • 从终端设置 git config tag.forceSignAnnotated true

这样,任何git tag -m "a comment" myTag将触发 gpgpSign。
仅适用于带注释的标签,但自 those are ones which are supposed to be not just local to your repo but also pushed ,这应该足够了。

关于git - 如何配置 git 始终对标签进行签名?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50646927/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com