Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Autosigning in Git not working

Tags:

git

github

gnupg

I'm trying to setup auto signing with git and gpg to Github but its not working.

I've got it to the point where, when I commit by the below it works and correctly signs my commits.

git commit -S

However despite running the below commands, I still can't autosign.

git config --global commit.gpgsign
git config --global user.signingkey <MY KEY>

contents of .gitconfig below.

[user]
        email = [email protected]
        signingKey = <MYKEY>
[commit]
        gpgsign = true
[gpg]
        program = gpg

Am I missing a step, or do you always have to type "git commit -S"?

Thanks

p.s. not interesting in a debate on whether you should autosign. Just accept that I want to :) I only commit from a protected VM, held on an encrypted laptop.

Solution: Update git to latest version. As I was using CentOS, I followed this post as it made it nice and easy. https://gist.github.com/mahamuniraviraj/ac4807c43694ec4d8d360ebf12e93df1

like image 803
NickS Avatar asked Apr 06 '26 03:04

NickS


1 Answers

You could check the following things:

  • git version is >= 2.2+
  • the casing of your gpgsign (should be gpgSign) - I would be surprised if this was the issue, considering that git config was case-insensitive for a long time

For more info, take a look at this SO question: Is there a way to "autosign" commits in Git with a GPG key?

Btw, the option "-s" is the "Signed off by", meaning it's not "-S" which is used for the signing. Maybe that was your issue?

like image 97
Mladen B. Avatar answered Apr 08 '26 17:04

Mladen B.