You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何配置Visual Studio 2022通过SSH/GPG密钥签名GitHub Git提交?

配置Visual Studio 2022实现GitHub Git提交签名的问题

在配置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 2022使用SSH或GPG密钥为GitHub的Git提交签名?


已找到的SSH签名解决方案

在Visual Studio 2022中使用SSH签名提交的步骤如下:

  1. 执行命令编辑全局Git配置文件:
    git config --global --edit
    
  2. 在配置文件中添加以下内容:
    [gpg "ssh"] sshCommand = C:/Windows/System32/OpenSSH/ssh.exe
    
  3. 依次运行以下命令:
    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推送提交后,在GitHub上会显示已验证标识。

内容的提问来源于stack exchange,提问作者eleve2023

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.22 22:54:57