我在配置Visual Studio 2022使用SSH或GPG密钥为GitHub签署Git提交方面遇到了问题。
我尝试使用以下命令设置GPG签名:
git config --global user.signingkey 3AA5C34371567BD2
git config --global commit.gpgsign true
然而,当我在Visual Studio中尝试提交时。
我会收到以下错误:
Your Git hook is not supported. This is probably because the first line is not "#!/bin/sh".
我检查了.git/hooks
目录中的所有文件,它们的第一行都是#!/bin/sh
。
如果我不设置git config --global commit.gpgsign true
,提交会通过,但在GitHub上标记为未验证。
如何正确配置Visual Studio使用SSH或GPG密钥为GitHub签署Git提交?任何帮助将不胜感激。
更新:
我找到了一个在Visual Studio 2022中使用SSH签署提交的解决方案。以下是我遵循的步骤:
- 使用命令
git config --global --edit
编辑gitConfig文件。 - 添加以下行:
[gpg "ssh"] sshCommand = C:/Windows/System32/OpenSSH/ssh.exe
。 - 运行以下命令:
git config --global gpg.format ssh
、git config --global user.signingkey /C:/Users/Admin/.ssh/id_signinged25519.pub
和git config --global commit.gpgsign true
。
现在,当我使用Visual Studio进行PUSH时,在GitHub上提交将具有已验证的标签。