Skip to main content

Integrate gpg for git commit sign

Use existing gpg tool in git

git config --global gpg.program "F:\soft\Git\usr\bin\gpg.exe"

View git configs (local, global)

git config --global --list
git config --local --list

Unset/Set git config (local, global)

git config --local --unset user.signingkey
git config --global--unset user.signingkey
git config --global --unset gpg.format
git config --global commit.gpgsign true
git config --global user.signingkey 14A98B3087087ECD

List gpg keys

"F:\soft\Git\usr\bin\gpg.exe" --list-secret-keys
"F:\soft\Git\usr\bin\gpg.exe" --list-secret-keys --keyid-format=long
"F:\soft\Git\usr\bin\gpg.exe" --list-keys

Generate gpg key

"F:\soft\Git\usr\bin\gpg.exe" --full-generate-key

Export gpg keys

"F:\soft\Git\usr\bin\gpg.exe" --armor --export 14A98B3087087ECD
"F:\soft\Git\usr\bin\gpg.exe" --export -a [email protected] > public.key
"F:\soft\Git\usr\bin\gpg.exe" -o private.gpg --export-options backup --export-secret-keys <[email protected]n>
"F:\soft\Git\usr\bin\gpg.exe" --export-secret-key -a [email protected] > private key

Import gpg keys

"F:\soft\Git\usr\bin\gpg.exe" --import-options restore --import private.gpg
"F:\soft\Git\usr\bin\gpg.exe" --edit-key <[email protected]n>
trust
quit
"F:\soft\Git\usr\bin\gpg.exe" --import public.key
"F:\soft\Git\usr\bin\gpg.exe" --import private.key