2

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 = nicholas.stocks@forcepoint.com
        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

NickS
  • 330
  • 4
  • 10
  • Can you explain exactly what is happening and what you're missing? Are you expecting to bypass entering your passphrase, or is it that it just won't sign at all unless you specify `-s` ? – Lasse V. Karlsen May 16 '18 at 11:54
  • it just won't sign at all unless I specify -s. Quite happy with being asked to enter my passphrase – NickS May 16 '18 at 11:54

1 Answers1

4

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?

Mladen B.
  • 2,784
  • 2
  • 23
  • 34
  • I was so hopeful you were right! That's the post I was following, I just updated to be gpgSign but alas still doesnt work – NickS May 16 '18 at 12:00
  • 2
    RE your point on git version. That may be the issue, seems CentOS installs 1.8.3.1 by default. Will upgrade and test, thanks! – NickS May 16 '18 at 12:03
  • 1
    Genius thankyou!! Upgraded to the latest (2.17.0-rc2) and it worked first time. Also you were right, I did mean "-S" not "-s" but that was just a typo in my Q – NickS May 16 '18 at 12:25
  • Cool :) Splendid :) – Mladen B. May 16 '18 at 12:25
  • After banging my head for far too long it turns out I was having the same issue of having git 1.8.3.1 installed... Excellent initial troubleshooting step – Cody B Feb 17 '20 at 22:28
  • I lost one hour just to notice that -s is not the same as -S... Thanks for this post! – dsax7 Nov 22 '20 at 13:35
  • @NickS thanks for closing the communication loop. – Student4K Nov 05 '21 at 12:18