当我gpg --list-secret-keys --keyid-format LONG在 git 中运行时,我根本没有显示任何键。另一方面,当我运行相同的命令时,cmd或者PowerShell我得到一个看起来像这样的输出
我还gpg.program通过运行在全局配置文件中添加了配置git config --global gpg.program "/c/Program Files (x86)/GnuPG/bin/gpg.exe"。无济于事。知道我可能做错了什么吗?顺便说一句,我只使用 git bash,并没有将 git 集成到 Windows 中。
我最终弄清楚了如何GPG4Win在 Git Bash 中使用
检查 GPG4Win 是否在您的 Windows 路径变量中
System variables PATH类似这样的行
添加gpg.program到git配置中
git config --global gpg.program "C:/Program Files (x86)/GnuPG/bin/gpg.exe"。这将确保它正在使用系统安装的gpg程序。注意:如果您仍然遇到问题,请将此行添加到您的~/.bashrc文件中并替换{Your User Directory}为您的用户名。
export GNUPGHOME="/c/Users/{Your User Directory}/AppData/Roaming/gnupg"
source ~/.bashrc # Adds the env you just added to your current session
Run Code Online (Sandbox Code Playgroud)
就是这样,您现在应该能够重新启动 git bash 并查看所有密钥或将密钥添加到 Windows 安装的gpg程序中。