【问题标题】:How to sign my commits to Github repository where I am not the owner?如何在我不是所有者的情况下签署我对 Github 存储库的提交?
【发布时间】:2020-03-30 20:43:13
【问题描述】:

我正在尝试在我关联的所有 Github 存储库中签署我的提交。当存储库由我托管时我可以签名,但当我只是贡献者时无法签名。每次我尝试这样做时都会收到下面提到的这个错误。

could not find identity matching specified user-id: <key id>
error: gpg failed to sign the data
fatal: failed to write commit object

下面是我的 .gitconfig 设置

[core]
        editor = \"C:\\Users\\user\\AppData\\Local\\Programs\\Microsoft VS Cod>
[user]
        email = <my email id>
        name = <my name>
        signingkey = <key id>
[commit]
        gpgsign = false
[gpg]
        program = gpg

我们将不胜感激。

【问题讨论】:

    标签: git github git-commit gnupg sign


    【解决方案1】:

    Github 与您在存储库的本地副本上签名的内容无关。从错误消息中,我假设您没有提供密钥 ID,因此 git 使用了您的提交者身份,该身份在 gpg 密钥库中没有相应的密钥。可能user.nameuser.email 配置值设置不正确。

    • 您可以检查这些值以及全局配置是否被本地设置意外覆盖:

      git config --show-origin user.name
      git config --show-origin user.email
      

      这些值应与gpg --list-secret-keys 输出中的键匹配。

    • 验证 gpg.programgpg.format 是否未设置。

    • 如果设置了user.signingKey,检查是否正确。
    • 或者只是比较两个 repos 的 git config --list 的输出。

    【讨论】:

    • 感谢您的回复。我已经在全局范围内设置了我的user.nameuser.email,并且对我的托管存储库的提交进行得非常好,但不是其他托管存储库。
    • 你说的我已经检查过了,本地配置也和秘钥里的一样。
    • 是的,即使我在 Windows 操作系统中使用 git bash
    • 不,我只尝试使用 GnuPG 对提交进行签名。
    • 程序已设置。我已经用我的 .gitconfig 设置更新了我的问题。
    【解决方案2】:

    尝试清除 git 缓存或从您的电脑中删除 repo 并重新克隆它并尝试签署您的下一个提交。让我知道它是否有效。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-01-22
      • 1970-01-01
      • 1970-01-01
      • 2018-05-06
      • 2012-01-17
      • 1970-01-01
      • 2019-07-12
      • 1970-01-01
      相关资源
      最近更新 更多