如何将提交的 ssh 密码保留 1 小时?

How to retain commit ssh passphrase for 1 hour?

我已将此选项添加到我的 .gitconfig

[commit]
  gpgsign = true

但是 Git 每次提交时都会询问我的密码。我不想用空密码创建一个新的密钥对。我宁愿 Git 保留我的密码几个小时。

这可能吗?

使用 gpg-agent 这样您只需输入一次密码。

gpg-agent is a daemon to manage secret (private) keys independently from any protocol.

如果使用 mac os,您可以使用 https://gpgtools.org/ 并将密码存储在钥匙串中。

来自 GitHub docs,查看提示部分:

To store your GPG key passphrase so you don't have to enter it every 
time you sign a commit, we recommend using the following tools:

For Mac users, the GPG Suite allows you to store your GPG key 
passphrase in the Mac OS Keychain.

For Windows users, the Gpg4win integrates with other Windows tools.

You can also manually configure gpg-agent to save your GPG key 
passphrase, but this doesn't integrate with Mac OS Keychain like
ssh-agent and requires more setup.
gpg: gpg-agent is not available in this session

如此处所述,这可能是因为 gpg-agent --versiongpg --version 不同。
仔细检查您的 $PATH:您可能会在一个文件夹中找到一个 gpg.exe,在另一个文件夹中找到一个 gpg-agent

此外,gpg-agent 应该与 gpg2 一起使用,而您使用的是 gpg 1...
参见“how to install gpg on cygwin? currently it's missing”。