Android Studio和Git - 如何通过GPG签署我的提交?

PND*_*NDA 22 windows git github gnupg android-studio

根据这个链接,我只需要-S使用我的GPG密钥包含交换机来签署我的提交,但我不知道如何在Android Studio中使用它.

如何在Android Studio中签署我的提交?

编辑:我很欣赏OSX解决方案的出现,但我真的希望看到一个适用于Windows的答案.我只使用我的Mac作为文档和东西.

小智 5

进行一些测试后我按照这个步骤进行操作请按照以下步骤重新启动Android Studio:

你是否厌倦了为每次提交写密码?

nano~/.gnupg/gpg.conf

添加以下行

use-agent
no-tty
default-key <your key id>
Run Code Online (Sandbox Code Playgroud)
  • 完成所有配置后,如果您使用MacOS.你应该:

ln -s /usr/local/Cellar/libgcrypt/1.7.0_1/usr/local/opt/libgcrypt

ln -s /usr/local/Cellar/libgpg-error/1.22/usr/local/opt/libgpg-error

ln -s /usr/local/Cellar/libassuan/2.4.2/usr/local/opt/libassuan

ln -s /usr/local/Cellar/pth/2.0.7/usr/local/opt/pth

  • 执行

来源〜/ .profile

  • 使用选项-S进行一次提交

git commit -am"我的提交消息"-S

  • 你应该得到一个密码提示. - 把你的密码

而已!!!


Von*_*onC 5

正如我在" 使用GPG签署git提交 "中提到的,使用Git 2.0:

如果要对所有提交进行GPG签名,则必须始终添加-S选项.
commit.gpgsign配置选项允许签署所有自动提交.

但这并不完全有效,接下来是问题127802,其中包含以下变通方法:

使用该内容创建了一个帮助脚本:

/usr/bin/gpg –batch –no-tty "$@"
Run Code Online (Sandbox Code Playgroud)

并设置gpg.program为该脚本

要么:

添加" no-tty"到" ~/.gnupg/gpg.conf"解决了我的问题.

您可能仍会收到错误消息:

Commit failed with error:
gpg: problem with the agent - disabling agent use
gpg: Sorry, no terminal at all requested - can't get input
error: gpg failed to sign the data
fatal: failed to write commit object
Run Code Online (Sandbox Code Playgroud)

再次:bug正在进行中,后面跟着问题110261:

除了之前的解决方案(OS X)之外,还要解决此问题:

1) brew install gnupg gnupg2 pinentry-mac

2)nano ~/.gnupg/gpg-agent.conf- > pinentry-program /usr/local/bin/pinentry-mac

3) git config -–global gpg.program gpg2