Verify Git Commit
Environment
- Currently using Windows 11.
- Visual Studio 2022 Community is installed.
- Git is also installed.
While following the steps from Microsoft to initialize a local git repository and push to a newly created git repository on GitHub using Visual Studio, some issues were encountered:
Issue: Visual Studio Repeatedly Requests Credentials ⚠️
Refer to this article. The sign-in options should use "System web browser" instead of the default "embedded browser auth" for "Add and reauthenticate accounts using."
Issue: Git Commit Failed with Git-Hook Error
Error message: "Your git-hook, 'gpg,' is not supported, likely because the first line is not '#!/bin/sh'.\r\nSee your administrator for additional assistance."
When initializing the git repository, a hook for GPG is added. GPG stands for The GNU Privacy Guard. When used on GitHub, it helps "to sign commits associated with your account on GitHub, you can add a public GPG key to your personal account"
Solution:
Refer to this link. Check if the file C:\Program Files\Git\usr\bin\gpg.exe
exists. By default, Visual Studio should install it. If not, install gpg.exe first.
After installation, add the GPG bin folder (by default C:\Program Files\Git\usr\bin
) to your %PATH%
.
Issue: "Error: cannot spawn C:\Program Files (x86)\GnuPG\bin\gpg.exe: No such file or directory"
Once gpg.exe is installed, set the path of gpg.exe in git config using git config --global gpg.program "C:\Program Files\Git\usr\bin\gpg.exe"
to ensure that git can find gpg.
Issue: "gpg: skipped: No secret key"
Error message: "gpg: signing failed: No secret key." This means there is no GPG secret key. Generating a new GPG key and inform Git about your GPG key.
(Optional) For GitHub Verification, ensure you have:
Then finally, you would got your commit verified..